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

How do you find when a velocity changes?

Asked by 7 years ago
Edited 7 years ago

I am having trouble finding when a value changes, namely the magnitude of the velocity of a head. Here's what I have so far:

local Head = script.Parent:FindFirstChild("Head")

Head.Changed:connect(function(property)
    warn(property)
    if property == "Velocity" then
        print("Velocity Change")
        if Head.Velocity.Magnitude > 1 then
            print(Head.Velocity.Magnitude)
            wait(0.1)
        end
    end
end)

(Its in StarterCharacterScripts)

What am I doing wrong?

1 answer

Log in to vote
0
Answered by 7 years ago

You need to define the Velocity, so you will need something like this

local head = script.Parent:WaitForChild('Head').BodyVelocity.Value --I recommend using WaitForChild instead of FindFirstChild to prevent issues on the server. And I also don't know how the Velocity is named in your case.
Ad

Answer this question