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

How can I find out when the velocity of an part has been changed? What event would I use?

After doing some research, I found that the Changed event, which fires when a property of an object changes, does not fire when the velocity of that object has changed. I am working on a script to keep a player on a (will be in game) uncontrollable platform, and I need the exact moment on which the velocity of the part it is standing on changes. I already know how to find the platform, I just need to know which event to use. Help?

1 answer

✓ Accepted answer

There isn't necessarily an event for that, but you could make a function that checks if the old velocity is different from the current velocity in a while loop.

local part = workspace.Part --Define the part
local oldVel = part.Velocity --define initial velocity

function hasChanged(part)
	if part.Velocity ~= oldVel then
		oldVel = part.Velocity
		return true
	else
		return false
	end
end

while wait() do
	if hasChanged(part) == true then
	--your code
	end
end

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