Guest User

Weapon LocalHost

a guest
Aug 28th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. local tool = script.Parent --get tool--
  2. local player = game:GetService("Players").LocalPlayer--get player--
  3. local mouse = player:GetMouse()--get mouse--
  4. local sound = tool:WaitForChild("Gunfire")
  5. local torso = "" -- noting--
  6. local reloading = false -- var check reloading ok--
  7. local contextActionService = game:GetService("ContextActionService") -- work for mobile bruh --
  8. local bodytype = nil --nil ok n ow but chekclaterifplayerisr15--
  9. local difference = 0 -- difference in head and mouse--
  10. local replicatedstorage = game:GetService("ReplicatedStorage")
  11. local bullets = tool:WaitForChild("Bullets")
  12. local reloadtime = 3
  13. --remote event--
  14. local equipAnimation = replicatedstorage:WaitForChild("EquipAnimation")
  15. local headshot = replicatedstorage:WaitForChild("Headshot")
  16. local reload = replicatedstorage:WaitForChild("Reload")
  17. local shootevent = replicatedstorage:WaitForChild("ShootEvent")
  18. local unequipanimation = replicatedstorage:WaitForChild("UnequipAnimation")
  19. -- REMOTE FUNCION!!!!!--
  20. local checkBodyType = replicatedstorage:WaitForChild("CheckBodyType")
  21. local fetchBulletsLeft = replicatedstorage:WaitForChild("FetchBulletsLeft")
  22. --Find body--
  23. function findBodyType() -- DETERMIN R15--
  24. bodytype = checkBodyType:InvokeServer(tool) -- invoke remote function to check on servefrafdsafa--
  25. print(bodytype)
  26. end
  27. --RELOAD FUNCTION--
  28. function reload()
  29. reloading = true
  30. reload:FireServer(tool.reload)
  31. wait(reloadtime)
  32. bullets.Value = 6
  33. equipAnimation:FireServer(tool.shoot)
  34. reloading = false
  35. end
  36. --WHEN TOOL ON EVEN WILL RUN--
  37. tool.Equipped:Connect(function(mouse)
  38. findBodyType() -- call function "heyyyyyyyyy i need to check body type."
  39. equipAnimation:FireServer(tool.shoot) -- calling equip animation so seerver play "YO PLAYPLAYPLAY"
  40. mouse.Button1Down:Connect(function()
  41. if bullets.Value <=0 or reloading == true then
  42. -- DON'T DO ANYTING --
  43. else
  44. local head = game.Workspace[player.Name].Head.CFrame.lookVector
  45. local mouse = CFrame.new(game.Workspace[player.Name].Head.Position,mouse.Hit.p).lookVector
  46. difference = (head-mouse)
  47. local ray = Ray.new(tool.Handle.CFrame.p,(player:GetMouse().Hit.p - tool.Handle.CFrame.p).unit*300)
  48. local part,position = game.Workspace:FindPartOnRay(ray,player.Character,false,true)
  49. soundTonguelay()
  50. if difference.magnitude < 1.33 then
  51. shootevent:FireServer(tool,position,part)
  52. bullets.Value = bullets.Value -1
  53. end
  54. end
  55. end)
  56. local reloadMobileButton = contextActionService:BindAction("ReloadBtn",reload,true,"r")
  57. contextActionService:SetPosition("ReloadBtn",UDim2.new(0.72,-25,0.20,-25))
  58. contextActionService:SetImage("ReloadBtn","http://www.roblox.com/asset/?id=10952420")
  59. end)
  60. tool.Unequipped:Connect(function()
  61. unequipanimation:FireServer(tool.shoot)
  62. contextActionService:UnbindAction("ReloadBtn")
  63. end)
  64. headshot.OnClientEvent:Connect(function()
  65.  
  66. end)
Advertisement
Add Comment
Please, Sign In to add comment