You are on page 1of 8

--Made by N3xul

local runDummyScript = function(f,scri)


local oldenv = getfenv(f)
local newenv = setmetatable({}, {
__index = function(_, k)
if k:lower() == 'script' then
return scri
else
return oldenv[k]
end
end
})
setfenv(f, newenv)
ypcall(function() f() end)
end
cors = {}
mas = Instance.new("Model",game:GetService("Lighting"))
mas.Name = "CompiledModel"
o1 = Instance.new("Tool")
o2 = Instance.new("Part")
o3 = Instance.new("SpecialMesh")
o4 = Instance.new("Sound")
o5 = Instance.new("Sound")
o6 = Instance.new("PointLight")
o8 = Instance.new("LocalScript")
o9 = Instance.new("Sound")
o10 = Instance.new("LocalScript")
o11 = Instance.new("Script")
o1.Name = "LaserGun"
o1.Parent = mas
o1.TextureId = "http://www.roblox.com/asset?id=130093050"
o1.GripPos = Vector3.new(0, -0.100000001, 0.75)
o1.CanBeDropped = false
o2.Name = "Handle"
o2.Parent = o1
o2.Position = Vector3.new(6.44000006, 0.670018971, 89.4400024)
o2.Rotation = Vector3.new(-180, 0, -180)
o2.CanCollide = false
o2.FormFactor = Enum.FormFactor.Custom
o2.Size = Vector3.new(0.580000222, 1.34000099, 2.48000145)
o2.CFrame = CFrame.new(6.44000006, 0.670018971, 89.4400024, -1, 0, 0, 0, 1, 0, 0,
0, -1)
o2.BottomSurface = Enum.SurfaceType.Smooth
o2.TopSurface = Enum.SurfaceType.Smooth
o2.Position = Vector3.new(6.44000006, 0.670018971, 89.4400024)
o3.Parent = o2
o3.MeshId = "http://www.roblox.com/asset?id=130099641"
o3.Scale = Vector3.new(0.649999976, 0.649999976, 0.649999976)
o3.TextureId = "http://www.roblox.com/asset/?id=130267361"
o3.MeshType = Enum.MeshType.FileMesh
o4.Name = "Fire"
o4.Parent = o2
o4.Pitch = 1.2000000476837
o4.SoundId = "http://www.roblox.com/asset?id=114488148"
o4.Volume = 1
o5.Name = "Reload"
o5.Parent = o2
o5.Pitch = 0.5
o5.SoundId = "http://www.roblox.com/asset?id=94255248"
o6.Parent = o2
o6.Color = Color3.new(1, 0, 0)
o6.Brightness = 4
o6.Range = 6
o8.Name = "ToolScript"
o8.Parent = o1
table.insert(cors,coroutine.create(function()
wait()
runDummyScript(function()
-----------------
--| Constants |--
-----------------

local SHOT_SPEED = 100


local SHOT_TIME = 1000

local NOZZLE_OFFSET = Vector3.new(0, 0.4, -1.1)

-----------------
--| Variables |--
-----------------

local PlayersService = Game:GetService('Players')


local DebrisService = Game:GetService('Debris')

local Tool = script.Parent


local Handle = Tool:WaitForChild('Handle')

local FireSound = Handle:WaitForChild('Fire')


local ReloadSound = Handle:WaitForChild('Reload')
local HitFadeSound = script:WaitForChild('HitFade')

local PointLight = Handle:WaitForChild('PointLight')

local Character = nil


local Humanoid = nil
local Player = nil

local BaseShot = nil

-----------------
--| Functions |--
-----------------

-- Returns a character ancestor and its Humanoid, or nil


local function FindCharacterAncestor(subject)
if subject and subject ~= Workspace then
local humanoid = subject:FindFirstChild('Humanoid')
if humanoid then
return subject, humanoid
else
return FindCharacterAncestor(subject.Parent)
end
end
return nil
end

-- Removes any old creator tags and applies new ones to the specified target
local function ApplyTags(target)
while target:FindFirstChild('creator') do
target.creator:Destroy()
end

local creatorTag = Instance.new('ObjectValue')


creatorTag.Value = Player
creatorTag.Name = 'creator' --NOTE: Must be called 'creator' for website
stats

local iconTag = Instance.new('StringValue')


iconTag.Value = Tool.TextureId
iconTag.Name = 'icon'

iconTag.Parent = creatorTag
creatorTag.Parent = target
DebrisService:AddItem(creatorTag, 4)
end

-- Returns all objects under instance with Transparency


local function GetTransparentsRecursive(instance, partsTable)
local partsTable = partsTable or {}
for _, child in pairs(instance:GetChildren()) do
if child:IsA('BasePart') or child:IsA('Decal') then
table.insert(partsTable, child)
end
GetTransparentsRecursive(child, partsTable)
end
return partsTable
end

local function SelectionBoxify(instance)


local selectionBox = Instance.new('SelectionBox')
selectionBox.Adornee = instance
selectionBox.Color = BrickColor.new('Really red')
selectionBox.Parent = instance
return selectionBox
end

local function Light(instance)


local light = PointLight:Clone()
light.Range = light.Range + 2
light.Parent = instance
end

local function FadeOutObjects(objectsWithTransparency, fadeIncrement)


repeat
local lastObject = nil
for _, object in pairs(objectsWithTransparency) do
object.Transparency = object.Transparency + fadeIncrement
lastObject = object
end
wait()
until lastObject.Transparency >= 1 or not lastObject
end

local function Dematerialize(character, humanoid, firstPart)


humanoid.WalkSpeed = 0

local parts = {}
for _, child in pairs(character:GetChildren()) do
if child:IsA('BasePart') then
child.Anchored = true
table.insert(parts, child)
elseif child:IsA('LocalScript') or child:IsA('Script') then
child:Destroy()
end
end

local selectionBoxes = {}

local firstSelectionBox = SelectionBoxify(firstPart)


Light(firstPart)
wait(0.05)

for _, part in pairs(parts) do


if part ~= firstPart then
table.insert(selectionBoxes, SelectionBoxify(part))
Light(part)
end
end

local objectsWithTransparency = GetTransparentsRecursive(character)


FadeOutObjects(objectsWithTransparency, 0.1)

wait(0.5)

humanoid.Health = 0
DebrisService:AddItem(character, 2)

local fadeIncrement = 0.05


Delay(0.2, function()
FadeOutObjects({firstSelectionBox}, fadeIncrement)
if character then
character:Destroy()
end
end)
FadeOutObjects(selectionBoxes, fadeIncrement)
end

local function OnTouched(shot, otherPart)


local character, humanoid = FindCharacterAncestor(otherPart)
if character and humanoid and character ~= Character then
ApplyTags(humanoid)
if shot then
local hitFadeSound = shot:FindFirstChild(HitFadeSound.Name)
if hitFadeSound then
hitFadeSound.Parent = humanoid.Torso
hitFadeSound:Play()
end
shot:Destroy()
end
Dematerialize(character, humanoid, otherPart)
end
end

local function OnEquipped()


Character = Tool.Parent
Humanoid = Character:WaitForChild('Humanoid')
Player = PlayersService:GetPlayerFromCharacter(Character)
end

local function OnActivated()


if Tool.Enabled and Humanoid.Health > 0 then
Tool.Enabled = false

FireSound:Play()

local handleCFrame = Handle.CFrame


local firingPoint = handleCFrame.p +
handleCFrame:vectorToWorldSpace(NOZZLE_OFFSET)
local shotCFrame = CFrame.new(firingPoint, Humanoid.TargetPoint)

local laserShotClone = BaseShot:Clone()


laserShotClone.CFrame = shotCFrame + (shotCFrame.lookVector *
(BaseShot.Size.Z / 2))
local bodyVelocity = Instance.new('BodyVelocity')
bodyVelocity.velocity = shotCFrame.lookVector * SHOT_SPEED
bodyVelocity.Parent = laserShotClone
laserShotClone.Touched:connect(function(otherPart)
OnTouched(laserShotClone, otherPart)
end)
DebrisService:AddItem(laserShotClone, SHOT_TIME)
laserShotClone.Parent = Tool

wait(0) -- FireSound length

ReloadSound:Play()
wait(0) -- ReloadSound length

Tool.Enabled = true
end
end

local function OnUnequipped()

end

--------------------
--| Script Logic |--
--------------------

BaseShot = Instance.new('Part')
BaseShot.Name = 'Effect'
BaseShot.FormFactor = Enum.FormFactor.Custom
BaseShot.Size = Vector3.new(0.2, 0.2, 3)
BaseShot.CanCollide = false
BaseShot.BrickColor = BrickColor.new('Really red')
SelectionBoxify(BaseShot)
Light(BaseShot)
HitFadeSound:Clone().Parent = BaseShot

Tool.Equipped:connect(OnEquipped)
Tool.Unequipped:connect(OnUnequipped)
Tool.Activated:connect(OnActivated)
end,o8)
end))
o9.Name = "HitFade"
o9.Parent = o8
o9.SoundId = "http://www.roblox.com/asset?id=130113415"
o10.Name = "MouseIcon"
o10.Parent = o1
table.insert(cors,coroutine.create(function()
wait()
runDummyScript(function()
local MOUSE_ICON = 'rbxasset://textures/GunCursor.png'
local RELOADING_ICON = 'rbxasset://textures/GunWaitCursor.png'

local Tool = script.Parent

local Mouse = nil

local function UpdateIcon()


if Mouse then
Mouse.Icon = Tool.Enabled and MOUSE_ICON or RELOADING_ICON
end
end

local function OnEquipped(mouse)


Mouse = mouse
UpdateIcon()
end

local function OnChanged(property)


if property == 'Enabled' then
UpdateIcon()
end
end

Tool.Equipped:connect(OnEquipped)
Tool.Changed:connect(OnChanged)

end,o10)
end))
o11.Name = "Shu_hold"
o11.Parent = o1
table.insert(cors,coroutine.create(function()
wait()
runDummyScript(function()
--This script gives you a next-gen hold script better than the current one. You
actually hold the barrel parallel to your face. Put it in any gun you want.
Original script by Xliver101, Converted to universal script by ToastyToaster.

selected = false
RSH, LSH = nil, nil
GRP = nil
RW, LW = Instance.new("Weld"), Instance.new("Weld")
anim = "none"
function WaitForChild(obj, ch_n)
local t = time()
while not obj:FindFirstChild(ch_n) and time() - t < 10 do wait(0.1) end
return obj:FindFirstChild(ch_n)
end
script.Parent.Equipped:connect(function()
if selected then return end
selected = true
player = game.Players:playerFromCharacter(script.Parent.Parent)
local ch = script.Parent.Parent
WaitForChild(ch, "Torso")
RSH = WaitForChild(ch.Torso, "Right Shoulder")
LSH = WaitForChild(ch.Torso, "Left Shoulder")
GRP = WaitForChild(ch["Right Arm"], "RightGrip")
_G.Grip = GRP
--
RSH.Part1 = nil
LSH.Part1 = nil
--
RW.Part0 = ch.Torso
RW.C0 = CFrame.new(1.5, 0.5, 0) --* CFrame.fromEulerAnglesXYZ(1.3, 0, -0.5)
RW.C1 = CFrame.new(0, 0.5, 0)
RW.Part1 = ch["Right Arm"]
RW.Parent = ch.Torso
_G.R = RW
--
LW.Part0 = ch.Torso
LW.C0 = CFrame.new(-1.5, 0.5, 0) --* CFrame.fromEulerAnglesXYZ(1.7, 0, 0.8)
LW.C1 = CFrame.new(0, 0.5, 0)
LW.Part1 = ch["Left Arm"]
LW.Parent = ch.Torso
_G.L = LW
--
GRP.C0 = CFrame.new(0, -1, -0.5) * CFrame.fromEulerAnglesXYZ(-1.22, -0.45,
0.22)
for i = 0, 1, 0.05 do
wait()
RW.C0 = CFrame.new(1.5, 0.5, 0.25) * CFrame.fromEulerAnglesXYZ(1.3*i,
0, -0.5*i)
LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.7*i, 0,
0.8*i)
LW.C1 = CFrame.new(0.3*i, 1+1*i, 0)
end
wait()
local rg = (ch["Right Arm"]:FindFirstChild("RightGrip") or GRP)
if rg ~= GRP then
GRP.Parent = ch["Right Arm"]
rg:remove()
end
end)
script.Parent.Unequipped:connect(function()
selected = false
local pl = player
RW.C0 = CFrame.new(0,0,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
LW.C0 = CFrame.new(0,0,0) * CFrame.fromEulerAnglesXYZ(0,0,0)
LW.C1 = CFrame.new(0,0,0)
RW.Parent = nil
LW.Parent = nil
RSH.Part1 = pl.Character["Right Arm"]
LSH.Part1 = pl.Character["Left Arm"]
end)
function armReload()
for i = 0, 1, 0.1 do
wait()
LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.3*i, 0,
0.9*i)
LW.C1 = CFrame.new(0.3*i, 1+1*i, 0)
end
end
function gunOut()
for i = 0, 0.3, 0.06 do
wait()
GRP.C0 = CFrame.new(0+i, -1-i, 0+(2*i)) * CFrame.fromEulerAnglesXYZ(-
2.22, -0.45, 0.42)
LW.C0 = CFrame.new(-1, 0.5, 0) * CFrame.fromEulerAnglesXYZ(4.2, 0, 2.9)

LW.C1 = CFrame.new(0.8*i, 1.1+i, -0.3)


end
end
function gunReturn()
RW.C0 = CFrame.new(1.5, 0.5, 0.25) * CFrame.fromEulerAnglesXYZ(1.3, 0, -0.5)
LW.C0 = CFrame.new(-1.5, 0.5, 0) * CFrame.fromEulerAnglesXYZ(1.7, 0, 0.8)
LW.C1 = CFrame.new(0.3, 1+1, 0)
GRP.C0 = CFrame.new(0, -1, -0.5) * CFrame.fromEulerAnglesXYZ(-1.22, -0.45,
0.22)
end
end,o11)
end))
mas.Parent = workspace
mas:MakeJoints()
local mas1 = mas:GetChildren()
for i=1,#mas1 do
mas1[i].Parent = game:GetService("Players").LocalPlayer.Backpack
ypcall(function() mas1[i]:MakeJoints() end)
end
mas:Destroy()
for i=1,#cors do
coroutine.resume(cors[i])
end

You might also like