How to move player a certain amount of studs towards mouse

Hey Scripters, I was wondering how I can make the player move a certain amount of studs towards the mouse (without raycasting), I’ve been trying to do this for a while for my how to make a game like super power training simulator YouTube series (for the teleportation power). I couldn’t find out how to do it any help appreciated.

Also bonus question for anyone that know: What is the formula the SPTS creators use to determine teleportation distance. Rn I’m just using 10000 power = 5 studs

2 Likes

uhh since youre teleporting why dont you just change the CFrame of the characters humrootpart towards the mouse

1 Like

Look, I know how to teleport (to the mouse too) but I can’t figure out how to make it move only a certain amount of studs in the direction of the mouse (without raycasting)

probably using raycast cuz you can add a limit to raycast

or you can use mouse.hit.p-humroot.Position.magnitude to check fir the distance between char and the mouse click and see if its more then dont tp if its less then tp

That’s what I was thinking I just wanted to know if there was another way. That’s why I asked. I guess not though

This would work but would be kinda inconsistent I feel.

The best way to do it would probably be raycasting, it will ensure that you don’t have people teleporting through walls and such.

I figured, just wanted to know if it was possible any other way

There are more ways, but it requires more maths I think.

Get the direction using something along the lines of (MousePos - RootPos).Unit and then multiply it by the distance. p.s this is vector3

1 Like

I’ll try that. Even if I can’t get that to work that will be useful for other stuff. And anyways I’ll be able to do the raycasting.