Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Script by ferano
- local tool = script.Parent
- local handle = tool:WaitForChild("Handle")
- firerate = 2
- local check = true
- local range = 150
- local event = tool:WaitForChild("RemoteEvent")
- local shot = handle:WaitForChild("FireSound")
- function checkintangible(hit)
- if hit and hit~=nil then
- 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
- return true
- end
- end
- return false
- end
- function castray(startpos,vec,length,ignore,delayifhit)
- local hit,endpos2=game.Workspace:FindPartOnRay(Ray.new(startpos,vec*length),ignore)
- if hit~=nil then
- if checkintangible(hit) then
- if delayifhit then
- wait()
- end
- hit,endpos2 = castray(endpos2+(vec*.01), vec, length-((startpos-endpos2).magnitude), ignore, delayifhit)
- end
- end
- return hit,endpos2
- end
- tool.Equipped:connect(function(mouse)
- equipped = true
- if mouse then
- mouse.Icon = "rbxasset://tesxtures\\GunCursor.png"
- mouse.Button1Down: connect(function()
- local humanoid = tool.Parent:FindFirstChild("Humanoid")
- local head = tool.Parent:FindFirstChild("Head")
- local torso = tool.Parent:FindFirstChild("Torso")
- if check and humanoid and humanoid.Health > 0 then
- check = false
- shot:Play()
- local vec = ((mouse.Hit.p - head.Position).unit)
- local hit, endpos = castray(head.Position, vec, range, tool.Parent)
- event:FireServer("Fire", endpos, hit)
- wait(firerate)
- if mouse then
- end
- check = true
- end
- end)
- end
- end)
- tool.Unequipped:connect(function()
- equipped = false
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement