Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 9 years ago

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

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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
Ad

Answer this question