Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. -- Script by ferano
  2.  
  3. local tool = script.Parent
  4. local handle = tool:WaitForChild("Handle")
  5. firerate = 2
  6. local check = true
  7. local range = 150
  8. local event = tool:WaitForChild("RemoteEvent")
  9. local shot = handle:WaitForChild("FireSound")
  10.  
  11. function checkintangible(hit)
  12. if hit and hit~=nil then
  13. if hit:IsDescendantOf(tool.Parent) or hit.CanCollide==false or string.lower(string.sub(hit.Name,1,6))=="effect" or string.lower(hit.Name)=="water" or hit.Name=="Arrow" then
  14. return true
  15. end
  16. end
  17. return false
  18. end
  19.  
  20. function castray(startpos,vec,length,ignore,delayifhit)
  21. local hit,endpos2=game.Workspace:FindPartOnRay(Ray.new(startpos,vec*length),ignore)
  22. if hit~=nil then
  23. if checkintangible(hit) then
  24. if delayifhit then
  25. wait()
  26. end
  27. hit,endpos2 = castray(endpos2+(vec*.01), vec, length-((startpos-endpos2).magnitude), ignore, delayifhit)
  28. end
  29. end
  30. return hit,endpos2
  31. end
  32.  
  33. tool.Equipped:connect(function(mouse)
  34. equipped = true
  35. if mouse then
  36. mouse.Icon = "rbxasset://tesxtures\\GunCursor.png"
  37. mouse.Button1Down: connect(function()
  38. local humanoid = tool.Parent:FindFirstChild("Humanoid")
  39. local head = tool.Parent:FindFirstChild("Head")
  40. local torso = tool.Parent:FindFirstChild("Torso")
  41. if check and humanoid and humanoid.Health > 0 then
  42. check = false
  43.  
  44. shot:Play()
  45.  
  46. local vec = ((mouse.Hit.p - head.Position).unit)
  47. local hit, endpos = castray(head.Position, vec, range, tool.Parent)
  48.  
  49. event:FireServer("Fire", endpos, hit)
  50.  
  51. wait(firerate)
  52. if mouse then
  53. end
  54. check = true
  55.  
  56. end
  57. end)
  58. end
  59. end)
  60.  
  61. tool.Unequipped:connect(function()
  62. equipped = false
  63. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement