So , i made a ragdoll script that create a ragdoll of the character when they got hit by a spell.
So all the script is working fine here the proof : https://gyazo.com/e1afb6a0f37bc248bef76e1a4d8c3914
But now i want the player to the player to be tp to his ragdoll when the ragdoll doesnt move anymore , The problem is that i dont know how to know when a part doesnt move anymore . I tried the velocity , the moveto with the humanoid but noting is working so… if u know help me
You could just compare the last known position of the character’s torso with its current position every second or so.
If so much distance has been covered, it would mean it’s still moving.
Or just check the torso’s velocity so the same.
Your best bet is to do what @WingItMan said. Check the magnitude of the last known position of the torso and wait till it becomes 0.
For example, it’d look like this.
local Torso = Character.UpperTorso
local LastTorsoPosition = Character.UpperTorso.Position
while (LastTorsoPosition - Torso.Position).Magnitude > 0 do --Could do > 0.1 just in case for physics glitches
LastTorsoPosition = Character.UpperTorso.Position
wait(0.1)
end
-- Do teleport stuff here
Alternate version.
repeat wait() until Torso.Velocity.Magnitude <= .05 --Not 0 cause simulated physics are weird