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

How to get a Changed event to work with BasePart.Velocity?

script.Parent.Parent.Parent.DriveSeat.Velocity:Connect(function()

this is what I have currently for this, and I am currently lost as the API reference doesn't help at all.

3 answers

You can either use .Changed or :GetPropertyChangedSignal("Property"), either way works.

script.Parent.Parent.Parent.DriveSeat:GetPropertyChangedSignal("Velocity"):Connect(function()
	--// Code
end)

Hope this helped! Don't forget to select this as the answer if this worked for you!

What if you just add-in an if statement like if script.Parent.Parent.Parent.DriveSeat.Velocity ~= 0 then --Code end

The problem:

Unfortunately as far as I know this is not currently possible as Velocity just like Position updates so often that it would fire way too often and would be too much overhead

The solution:

the only way to work around this is as far as I know is to use a while loop or a RunService Event i.e. Heartbeat and compare the last Velocity with the current Velocity

Example Heartbeat Code:

You can find an example for how to use Heartbeat here

Don't forget to mark my answer as the solution and upvote it if it helped :)

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