I’m not very good with math and I’ve tried but I can’t seem to figure it out.
I get a variable for the mouse position when the player clicks like this.
local mouseP = mouse.Hit.p
However I don’t want the player to be able to click super far away. So when the player clicks to far away, the mouseP variable will default to a value closer to the player.
local magnitude = (gun.Nozzle.Position - mouseP).Magnitude
if magnitude > range then
-- calculate the mouse position but closer to the player
end
I am not sure how to calculate this. Can anyone help me?
For magnitude compare the original position of the projectile with the current position, if the stud count exceeds a certain number then remove the projectile.