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

Changed value not firing?

Asked by
Mystdar 352 Moderation Voter
9 years ago

This is my script but it is not printing changed and the output says: 19:27:37.617 - Workspace.Soldier.Folder.Scripts.Move:10: attempt to index global 'Moving' (a boolean value)

Folder = script.Parent.Parent
Soldier = script.Parent.Parent.Parent
Torso = Soldier.Torso
Face = Torso.BodyGyro
Force = Torso.BodyVelocity
Location = Folder.Values.Location.Value
TargetLocation = Folder.Values.TargetLocation.Value
Moving = Folder.Values.Moving.Value

Moving.Changed:connect(function()
    print ("Changed")
    if Moving then
        while Moving and Location ~= TargetLocation do -- If Moving now is true and is not already at the target location 
            -- Play animation for legs?
            Face.CFrame = CFrame.new(Torso.Position, CFrame(TargetLocation)) --Face target location
            Force.velocity = Torso.CFrame.lookVector * 100 -- Move to target location   
        end
    elseif not Moving then -- If moving now is false
        -- Stop animation
        Face.CFrame = nil -- Will this stop it from facing the position, and just come to a rest, obviously still facing the position as it won't have changed, but it won't be 'bond' to it
        Force.velocity = Torso.CFrame.lookVector * 0
    end
end)

1 answer

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago
Moving = Folder.Values.Moving.Value

As you can see, Moving is the value's Value property, not the object itself. Properties don't have events. Therefore this is a simple fix:

Moving = Folder.Values.Moving

Moving.Changed:connect(function(property)
    print(property) --It will print what the property equals now.
end)
Ad

Answer this question