Making A Laser Gun

Hey there,

I am lookign to script a laser gun for my upcoming project. I am trying to make it able to shoot where a specific red light is shown (according to the cursor position). I would like the gun only to respond if it hits a specific part with a specific name, but am not sure how to make this in a way which can be challenging, but not too hard. It is going to be for a full-scale laser tag game, so it needs to work well.

Let me know if you have any suggestions!
Thanks,

1 Like

Raycasting would be perfect for this project.

Intro to raycasting article

I am assuming I would cast a ray in the direction of the cursor and check if it intersects a specific part?

1 Like

Yes! and you can filter through the instance it touched to get a specific part or player!

heres an example

local instance = rayresult.Instance

local char = instance:FindFirstAncestorWhichIsA("Model")
local player = game.Players:GetPlayerFromCharacter(char)
--etc

hope this helps!

1 Like

tbh im not sure if this is even a function :sweat_smile: but it should be! if its not just use findfirst ancestor or something