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

How do i create a back and forth moving brick?

this is all i got so far:

local Charge = 0

for Charge = 0, 20, 1 do
	script.Parent.Position = script.Parent.Position + Vector3.new(0, 0.1, 0)
	wait(0.01)
end

but it just makes it go up by .2 studs. how do i make a continuous motion?

1 answer

May not be consistent, but it works:

x = 0
y = 1
while y == 1 do -- just so it infinitely loops
	if x == 0 then 
		for x = 0, 20, 1 do
			script.Parent.Position = script.Parent.Position + Vector3.new(0, 0.1, 0)
		wait(0.01) -- so it doesn't crash
	if x == 20 then
		for x = 20, 0, -1 do
			script.Parent.Position = script.Parent.Position - Vector3.new(0, 0.1, 0)
			wait(0.01)
		end
		end
	end
	end
end


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