Advertisement
Blueisim

GScript(battle)

Jun 10th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.12 KB | None | 0 0
  1. wait(.3)
  2.  
  3. local deb=true
  4. local config=require(script.GunConfig)
  5. local ammo=config.ammo
  6. local mammo=config.mammo
  7. local tool = script.Parent
  8. local player = game:GetService("Players").LocalPlayer
  9. local pew=tool.Gunshot
  10. local rel=tool.Reload
  11. local remotes=workspace.Remotes
  12. local anims=tool.Anims
  13. local gui
  14. local guifunc
  15. local mousedown=false
  16. pew.SoundId=config.shotid
  17. rel.SoundId=config.reloid
  18. loadgui=function()
  19. gui=script.Parent.AmmoGui:Clone()
  20. gui.Parent=player.PlayerGui
  21. guifunc=game:GetService("RunService").Heartbeat:connect(function()
  22. if ammo>0 then
  23. gui.Ammo.Text=ammo.."/"..mammo
  24. else
  25. gui.Ammo.Text="Click to reload!"
  26. wait(config.reloadtime)
  27. end
  28. end)
  29. end
  30. removegui=function()
  31. if guifunc then
  32. guifunc:Disconnect()
  33. gui:Destroy()
  34. gui=nil
  35. end
  36. end
  37. function tag(humanoid)
  38. remotes.TagZombie:FireServer(humanoid.Parent,player)
  39. end
  40. function shot(mouse)
  41. if deb==true then
  42. if config.spray and config.spray==true then
  43. for i=1,6 do
  44. math.randomseed(math.random())
  45. local x=math.random(-config.spread,config.spread)
  46. math.randomseed(math.random())
  47. local y=math.random(-config.spread,config.spread)
  48. math.randomseed(math.random())
  49. local z=math.random(-config.spread,config.spread)
  50. local ray = Ray.new(tool.GunTip.CFrame.p, (mouse.Hit.p+Vector3.new(x,y,z) - tool.GunTip.CFrame.p).unit * 300)
  51. local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
  52. remotes.gun.CreateServerBullet:FireServer(tool.GunTip.CFrame.p,position+Vector3.new(x,y,z))
  53. deb=false
  54. coroutine.wrap(function()
  55. wait(config.shotspeed)
  56. deb=true
  57. end)()
  58.  
  59. if part and part.Parent.Parent==workspace.Zombies then
  60. local humanoid = part.Parent:FindFirstChild("Humanoid")
  61.  
  62. if not humanoid then
  63. humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
  64. end
  65.  
  66. if humanoid then
  67. remotes.DamageEvent:FireServer(humanoid,config.damage)
  68. tag(humanoid)
  69. end
  70. end
  71. end
  72. remotes.gun.PlaySound:FireServer(pew)
  73. ammo=ammo-1
  74. else
  75. local ray = Ray.new(tool.GunTip.CFrame.p, (mouse.Hit.p - tool.GunTip.CFrame.p).unit * 300)
  76. local part, position = workspace:FindPartOnRay(ray, player.Character, false, true)
  77. remotes.gun.CreateServerBullet:FireServer(tool.GunTip.CFrame.p,position)
  78. ammo=ammo-1
  79. deb=false
  80. coroutine.wrap(function()
  81. wait(config.shotspeed)
  82. deb=true
  83. end)()
  84. remotes.gun.PlaySound:FireServer(pew)
  85. if part and part.Parent.Parent==workspace.Zombies then
  86. local humanoid = part.Parent:FindFirstChild("Humanoid")
  87.  
  88. if not humanoid then
  89. humanoid = part.Parent.Parent:FindFirstChild("Humanoid")
  90. end
  91.  
  92. if humanoid then
  93. remotes.DamageEvent:FireServer(humanoid,config.damage)
  94. tag(humanoid)
  95. end
  96. end
  97. end
  98. end
  99. end
  100. tool.Equipped:connect(function(mouse)
  101. loadgui()
  102. rel:Play()
  103. local track=player.Character.Humanoid:LoadAnimation(anims.GunIdle)
  104. track:Play()
  105. track.Looped=true
  106. tool.Unequipped:connect(function()
  107. track:Stop()
  108. mousedown=false
  109. end)
  110. mouse.Button1Down:connect(function()
  111. if deb==true then
  112. if ammo>0 then
  113. shot(mouse)
  114. if config.auto==true then
  115. while mousedown and ammo>0 do
  116. shot(mouse)
  117. wait(config.shotspeed)
  118. end
  119. end
  120. else
  121. deb=false
  122. remotes.gun.PlaySound:FireServer(rel)
  123. wait(config.reloadtime)
  124. deb=true
  125. ammo=mammo
  126. end
  127. end
  128. end)
  129. mouse.Button1Down:connect(function()
  130. mousedown=true
  131. end)
  132. mouse.Button1Up:connect(function()
  133. mousedown=false
  134. end)
  135. end)
  136. tool.Unequipped:connect(function()
  137. removegui()
  138. end)
  139. local fakearms
  140. local larm
  141. local rarm
  142. if not workspace.Ignore:FindFirstChild(player.Name.."'s Fakearms") then
  143. fakearms=Instance.new("Model",workspace.Ignore)
  144. fakearms.Name=player.Name.."'s Fakearms"
  145. larm=Instance.new("Part",fakearms)
  146. larm.BrickColor=BrickColor.Black()
  147. larm.Size=Vector3.new(1,2,1)
  148. larm.CanCollide=false
  149. larm.Anchored=false
  150. larm.Position=player.Character["Left Arm"].Position
  151. larm.Name="larm"
  152. larm.Material=Enum.Material.SmoothPlastic
  153. larm.Massless=true
  154. rarm=Instance.new("Part",fakearms)
  155. rarm.BrickColor=BrickColor.Black()
  156. rarm.Size=Vector3.new(1,2,1)
  157. rarm.CanCollide=false
  158. rarm.Anchored=false
  159. rarm.Position=player.Character["Right Arm"].Position
  160. rarm.Name="rarm"
  161. rarm.Material=Enum.Material.SmoothPlastic
  162. rarm.Massless=true
  163. local w1=Instance.new("Weld",player.Character["Left Arm"])
  164. w1.Part0=w1.Parent
  165. w1.Part1=larm
  166. local w2=Instance.new("Weld",player.Character["Right Arm"])
  167. w2.Part0=w2.Parent
  168. w2.Part1=rarm
  169. else
  170. fakearms=workspace.Ignore:FindFirstChild(player.Name.."'s Fakearms")
  171. larm=fakearms.larm
  172. rarm=fakearms.rarm
  173. end
  174. function showfakearms()
  175. larm.Transparency=0.5
  176. rarm.Transparency=0.5
  177. end
  178. function hidefakearms()
  179. larm.Transparency=1
  180. rarm.Transparency=1
  181. end
  182. hidefakearms()
  183. coroutine.wrap(function()
  184. while wait() do
  185. local zoom=((math.floor(((workspace.CurrentCamera.CoordinateFrame.p - player.Character.Head.Position).magnitude)*10))/10)
  186. if zoom<=0.5 then
  187. showfakearms()
  188. else
  189. hidefakearms()
  190. end
  191. end
  192. end)()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement