Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- wait(.3)
- local deb=true
- local config=require(script.GunConfig)
- local ammo=config.ammo
- local mammo=config.mammo
- local tool = script.Parent
- local player = game:GetService("Players").LocalPlayer
- local pew=tool.Gunshot
- local rel=tool.Reload
- local remotes=workspace.Remotes
- local anims=tool.Anims
- local gui
- local guifunc
- local mousedown=false
- pew.SoundId=config.shotid
- rel.SoundId=config.reloid
- loadgui=function()
- gui=script.Parent.AmmoGui:Clone()
- gui.Parent=player.PlayerGui
- guifunc=game:GetService("RunService").Heartbeat:connect(function()
- if ammo>0 then
- gui.Ammo.Text=ammo.."/"..mammo
- else
- gui.Ammo.Text="Click to reload!"
- wait(config.reloadtime)
- end
- end)
- end
- removegui=function()
- if guifunc then
- guifunc:Disconnect()
- gui:Destroy()
- gui=nil
- end
- end
- function tag(humanoid)
- remotes.TagZombie:FireServer(humanoid.Parent,player)
- end
- function shot(mouse)
- if deb==true then
- if config.spray and config.spray==true then
- for i=1,6 do
- math.randomseed(math.random())
- local x=math.random(-config.spread,config.spread)
- math.randomseed(math.random())
- local y=math.random(-config.spread,config.spread)
- math.randomseed(math.random())
- local z=math.random(-config.spread,config.spread)
- local ray = Ray.new(tool.GunTip.CFrame.p, (mouse.Hit.p+Vector3.new(x,y,z) - tool.GunTip.CFrame.p).unit * 300)
- local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
- remotes.gun.CreateServerBullet:FireServer(tool.GunTip.CFrame.p,position+Vector3.new(x,y,z))
- deb=false
- coroutine.wrap(function()
- wait(config.shotspeed)
- deb=true
- end)()
- if part and part.Parent.Parent==workspace.Zombies then
- local humanoid = part.Parent:FindFirstChild("Humanoid")
- if not humanoid then
- humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
- end
- if humanoid then
- remotes.DamageEvent:FireServer(humanoid,config.damage)
- tag(humanoid)
- end
- end
- end
- remotes.gun.PlaySound:FireServer(pew)
- ammo=ammo-1
- else
- local ray = Ray.new(tool.GunTip.CFrame.p, (mouse.Hit.p - tool.GunTip.CFrame.p).unit * 300)
- local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
- remotes.gun.CreateServerBullet:FireServer(tool.GunTip.CFrame.p,position)
- ammo=ammo-1
- deb=false
- coroutine.wrap(function()
- wait(config.shotspeed)
- deb=true
- end)()
- remotes.gun.PlaySound:FireServer(pew)
- if part and part.Parent.Parent==workspace.Zombies then
- local humanoid = part.Parent:FindFirstChild("Humanoid")
- if not humanoid then
- humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
- end
- if humanoid then
- remotes.DamageEvent:FireServer(humanoid,config.damage)
- tag(humanoid)
- end
- end
- end
- end
- end
- tool.Equipped:connect(function(mouse)
- loadgui()
- rel:Play()
- local track=player.Character.Humanoid:LoadAnimation(anims.GunIdle)
- track:Play()
- track.Looped=true
- tool.Unequipped:connect(function()
- track:Stop()
- mousedown=false
- end)
- mouse.Button1Down:connect(function()
- if deb==true then
- if ammo>0 then
- shot(mouse)
- if config.auto==true then
- while mousedown and ammo>0 do
- shot(mouse)
- wait(config.shotspeed)
- end
- end
- else
- deb=false
- remotes.gun.PlaySound:FireServer(rel)
- wait(config.reloadtime)
- deb=true
- ammo=mammo
- end
- end
- end)
- mouse.Button1Down:connect(function()
- mousedown=true
- end)
- mouse.Button1Up:connect(function()
- mousedown=false
- end)
- end)
- tool.Unequipped:connect(function()
- removegui()
- end)
- local fakearms
- local larm
- local rarm
- if not workspace.Ignore:FindFirstChild(player.Name.."'s Fakearms") then
- fakearms=Instance.new("Model",workspace.Ignore)
- fakearms.Name=player.Name.."'s Fakearms"
- larm=Instance.new("Part",fakearms)
- larm.BrickColor=BrickColor.Black()
- larm.Size=Vector3.new(1,2,1)
- larm.CanCollide=false
- larm.Anchored=false
- larm.Position=player.Character["Left Arm"].Position
- larm.Name="larm"
- larm.Material=Enum.Material.SmoothPlastic
- larm.Massless=true
- rarm=Instance.new("Part",fakearms)
- rarm.BrickColor=BrickColor.Black()
- rarm.Size=Vector3.new(1,2,1)
- rarm.CanCollide=false
- rarm.Anchored=false
- rarm.Position=player.Character["Right Arm"].Position
- rarm.Name="rarm"
- rarm.Material=Enum.Material.SmoothPlastic
- rarm.Massless=true
- local w1=Instance.new("Weld",player.Character["Left Arm"])
- w1.Part0=w1.Parent
- w1.Part1=larm
- local w2=Instance.new("Weld",player.Character["Right Arm"])
- w2.Part0=w2.Parent
- w2.Part1=rarm
- else
- fakearms=workspace.Ignore:FindFirstChild(player.Name.."'s Fakearms")
- larm=fakearms.larm
- rarm=fakearms.rarm
- end
- function showfakearms()
- larm.Transparency=0.5
- rarm.Transparency=0.5
- end
- function hidefakearms()
- larm.Transparency=1
- rarm.Transparency=1
- end
- hidefakearms()
- coroutine.wrap(function()
- while wait() do
- local zoom=((math.floor(((workspace.CurrentCamera.CoordinateFrame.p - player.Character.Head.Position).magnitude)*10))/10)
- if zoom<=0.5 then
- showfakearms()
- else
- hidefakearms()
- end
- end
- end)()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement