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

Making a brick move then stop moving?

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

0

You can use for loop instead.

1 answer

✓ Accepted answer

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

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