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.

1 comment
You can use for loop instead.