Need help make laser sight for certain gun

  1. What do you want to achieve?
    Can i have script laser sight like video under, i try to making game and weapons for sniper but it request laser sight work for sniper trainee, please?
    Request to answer like this:

You know, you could just use A RemoteEvent and RunService to follow the mouse and for a beam attachment to position itself to the Mouse

I know it but many players have a bad aim when without a laser, I need it for my game, cause at the night Sniper can’t see their aim dot to get a headshot, mainly on high ground or in the forest to shoot the enemy, laser sight it help them fire target jump well than when without laser sight, I have trying to find good script laser sight and add inside the tool, it works a bit but it has a lot of bugs.

Then you obviously don’t know. This requires scripting, it’s not something someone will give you for free on the toolbox that magically works with all guns. I’ll hint you to it- get the player’s mouse with game.Players.LocalPlayer:GetMouse(). The mouse has a .Hit property, which is a raycast to the mouse in 3D space. You can do Mouse.Hit.Position to get where it landed, and in a RunService.RenderStepped event, set the laser’s attachment WorldPosition to Mouse.Hit.Position.

I will provide an example, but it’s best you read the text above as your use case may vary. Note that this does not replicate to other players, use a remote event for that (make sure it has a cooldown to prevent lag, though).

local RunService = game:GetService('RunService')
local Mouse = game:GetService('Players').LocalPlayer:GetMouse()

local Attachment = nil

-- Alternatively, you can use Mouse.Move or UserInputService.InputBegan,
-- ... which may fix lag on the server or client
RunService.RenderStepped:Connect(function()
     if attachment then
         attachment.WorldPosition = Mouse.Hit.Position
     end
end)
1 Like

Can tell me step by step to make it please to let me understand? @GibusWielder