Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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

This discussion is preserved as it was. New answers, comments, and votes are closed.