Advertisement
VoidScripteay72

Untitled

Feb 28th, 2023
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local UserInputService = game:GetService("UserInputService")
  3.  
  4. local LASER_COLOR = Color3.new(1, 0, 0) -- Red color for the laser
  5. local LASER_LENGTH = 10 -- Length of the laser in studs
  6.  
  7. local function onInputBegan(input, gameProcessedEvent)
  8. if input.KeyCode == Enum.KeyCode.E then
  9. local player = Players.LocalPlayer
  10. local character = player.Character
  11. local humanoid = character and character:FindFirstChildOfClass("Humanoid")
  12. if humanoid and humanoid.Health > 0 then
  13. local origin = character.Head.Position
  14. local direction = character.Head.CFrame.LookVector
  15. local ray = Ray.new(origin, direction * LASER_LENGTH)
  16. local part = Instance.new("Part")
  17. part.Anchored = true
  18. part.CanCollide = false
  19. part.Size = Vector3.new(0.2, 0.2, ray.Direction.Magnitude)
  20. part.CFrame = CFrame.new(origin, origin + direction * LASER_LENGTH / 2)
  21. part.Color = LASER_COLOR
  22. part.Parent = workspace
  23. local trail = Instance.new("Trail")
  24. trail.Attachment0 = part
  25. trail.Lifetime = 1
  26. trail.TextureMode = Enum.TextureMode.Decal
  27. trail.Transparency = NumberSequence.new({NumberSequenceKeypoint.new(0, 0), NumberSequenceKeypoint.new(1, 1)})
  28. trail.Color = ColorSequence.new(LASER_COLOR)
  29. trail.Parent = part
  30. end
  31. end
  32. end
  33.  
  34. UserInputService.InputBegan:Connect(onInputBegan)
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement