Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a range limit on Mouse.Hit?

Asked by 3 years ago
Edited 3 years ago

I want to make a teleport tool that has a range limit. Issue: I cannot figure out how to make a limit to it and I have looked endlessly throughout the internet trying to find a solution but couldn’t find one. Solutions: I did the magnitude of the character subtracted by the mouse position but I want to make it so that you can also teleport straight up. I also tried clamping each axis of the mouse position and it worked but if the mouse was out of range, the position messed up.

For example, I want it so that if you teleport to the sky, it teleports you [range] studs in that direction if there is no parts covering it.

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Sounds like you could use math.max or math.min

Player.pos = math.min(10, (plr.pos - mouse.hitpos).magnitude )

And if ur looking straight up just use If statement?

If mouse.hit == nil then

     Plr.pos = look vector * range

End
Ad

Answer this question