Advertisement
toonrun123

LaserPoint Player.

Jul 27th, 2019
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. --Laser Point
  2. --You can use Team and Fucking more.
  3. ---------------------------------------------------------
  4. local Players = game:GetService("Players")
  5. local RunService = game:GetService("RunService")
  6.  
  7. -- grab local player
  8. local localPlayer = Players.LocalPlayer
  9.  
  10. -- create beam
  11. local beam = Instance.new("Beam")
  12. beam.Segments = 1
  13. beam.Width0 = 0.2
  14. beam.Width1 = 0.2
  15. beam.Color = ColorSequence.new(Color3.fromRGB(255, 0, 0))
  16. beam.FaceCamera = true
  17.  
  18. -- create attachments
  19. local attachment0 = Instance.new("Attachment")
  20. local attachment1 = Instance.new("Attachment")
  21. beam.Attachment0 = attachment0
  22. beam.Attachment1 = attachment1
  23.  
  24. -- parent attachments to Terrain
  25. beam.Parent = workspace.Terrain
  26. attachment0.Parent = workspace.Terrain
  27. attachment1.Parent = workspace.Terrain
  28.  
  29. -- grab the mouse
  30. local mouse = localPlayer:GetMouse()
  31.  
  32. -- connect to RenderStepped (update every frame)
  33. RunService.RenderStepped:Connect(function()
  34.     if mouse.Target then
  35.     if mouse.Target.Parent:FindFirstChild("Humanoid") then
  36.         beam.Color = ColorSequence.new(Color3.fromRGB(31, 128, 29))
  37.     else
  38.         beam.Color = ColorSequence.new(Color3.fromRGB(255, 0, 0))
  39.     end
  40.  
  41.     -- make sure the character exists
  42.     local character = localPlayer.Character
  43.     if not character then
  44.         -- disable the beam
  45.         beam.Enabled = false
  46.         return
  47.     end
  48.  
  49.     -- make sure the head exists
  50.     local head = character:FindFirstChild("HumanoidRootPart")
  51.     if not head then
  52.         -- disable the beam
  53.         beam.Enabled = false
  54.         return
  55.     end
  56.  
  57.     -- enable the beam
  58.     beam.Enabled = true
  59.  
  60.     -- define origin and finish
  61.     local origin = head.Position
  62.     local finish = mouse.Hit.p
  63.  
  64.     -- move the attachments
  65.     attachment0.Position = origin
  66.     attachment1.Position = finish
  67.     end
  68. end)
  69. --Yeah im so fucking headache.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement