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

Making a brick move then stop moving?

Asked by 5 years ago

I got a part that i want to move when a value isn't 0 and stops moving once the value reaches 0. This is the whole script:

local part = script.Parent
local X = part.position.X
local XNew = X + 0.05
local Y = part.position.Y
local Z = part.position.Z
local TrackCurrent = script.Parent.Parent.Parent.Utilities.ControlsA.TrackCurrent
local bool = false

local function Change()
    if TrackCurrent == 0 then
        bool = false
    else
        bool = true
    end
    if bool == true then
        repeat
            wait(0.1)
            part.CFrame = CFrame.new(XNew, Y, Z)
            wait(0.1)
            part.CFrame = CFrame.new(X, Y, Z)
        until bool == false
        part.CFrame = CFrame.new(X, X, Z)
    end
end

TrackCurrent.Changed:Connect(Change)

It all works up until the repeat. For some reason, even when i switch TrackCurrent to 0, the repeat continues. Note: i tried doing until TrackCurrent == 0 and it has the same results.

0
You can use for loop instead. SCP774 191 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

On line 10 change

TrackCurrent

To

TrackCurrent.Value

To compare to a number you need to check the Value property which is a number not the object itself

Ad

Answer this question