So I was wondering what would be the best way to detect if player moved for example 10studs?
Well you can use a while loop and keep updating a variable that says the latest player position and compare it with the actual position:
local lastPos = Character.PrimaryPart.Position
while wait(3) do
print((Character.PrimaryPart.Position - lastPos).Magnitude)
lastPos = Character.PrimaryPart.Position
end
3 Likes
If you want to find the actual distance they moved, you can use the .Magnitude
property
local lastPosition = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
while true do
local currentPosition = game.Players.LocalPlayer.Character.HumanoidRootPart.Position
print((currentPosition - lastPosition).Magnitude)
wait(1)
end
Note: you might want to ignore the Y axis as a player in free fall has infinite terminal velocity
1 Like
I think you misunderstood him, when he said X, he meant a variable, like x = 10, not how many studs the player walked in the X axis
Yeah I’m stupid sorry lol. I’m gonna change the script.
Thanks mate this is what I needed!!! Tysm
1 Like
Thanks mate this is what I needed!!! Thanks
1 Like
This one is the best. Thank you so much!!