Advertisement
JohnJohniamm55

sssssssssssssssssssssssssssss

Mar 28th, 2015
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. local tool = Instance.new("Tool",game.Players.TheDarkRevenant.Backpack)
  2. local part = Instance.new("Part",tool)
  3. part.Name = "Handle"
  4. local user
  5.  
  6. --when the tool is equipped
  7. tool.Equipped:connect(function(mouse)
  8. --store the character of the person using the tool
  9. user = tool.Parent
  10.  
  11. --when the left mouse button is clicked
  12. mouse.Button1Down:connect(function()
  13. --make and do a hit test along the ray
  14. local ray = Ray.new(tool.Handle.CFrame.p, (mouse.Hit.p - tool.Handle.CFrame.p).unit*300)
  15. local hit, position = game.Workspace:FindPartOnRay(ray, user)
  16.  
  17. --do damage to any humanoids hit
  18. local humanoid = hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid")
  19. if humanoid then
  20. humanoid:TakeDamage(30)
  21. end
  22.  
  23. --draw the ray
  24. local distance = (position - tool.Handle.CFrame.p).magnitude
  25. local rayPart = Instance.new("Part", user)
  26. rayPart.Name = "RayPart"
  27. rayPart.BrickColor = BrickColor.new("Bright red")
  28. rayPart.Transparency = 0.5
  29. rayPart.Anchored = true
  30. rayPart.CanCollide = false
  31. rayPart.TopSurface = Enum.SurfaceType.Smooth
  32. rayPart.BottomSurface = Enum.SurfaceType.Smooth
  33. rayPart.formFactor = Enum.FormFactor.Custom
  34. rayPart.Size = Vector3.new(0.2, 0.2, distance)
  35. rayPart.CFrame = CFrame.new(position, tool.Handle.CFrame.p) * CFrame.new(0, 0, -distance/2)
  36.  
  37. --add it to debris so it disappears after 0.1 seconds
  38. game.Debris:AddItem(rayPart, 0.1)
  39. end)
  40. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement