local Q=script.Parent local A=Q.Speed.Value local P=Q.Rate.Value local V=Vector3.new(1,0,0)part={move=function()local P=.03 for x=0,1,P do Q.CFrame=Q.CFrame+Vector3.new(P*V.X,0,0)if x%(A/10)==0 then print(x)wait()end end end}while true do nRate=P if nRate==1 then nRate=1 end V=V*1 for Q=1,nRate,1 do part:move()end wait()end
--[[

Rate = How far left / right it goes; if it's 0, then it will decide randomly between two numbers (Edit in script).
Speed = How many studs it moves per second; if the value is 1, it will move one stud every second; two if value is 2; etc.

--]]

local object = script.Parent
local speed = object.Speed.Value
local rate = object.Rate.Value
local direction = Vector3.new(1, 0, 0)

part = {
	move = function() -- Makes it a method :D
		local s = 0.03
		for d = 0, 1, s do
			object.CFrame = object.CFrame + Vector3.new(s * direction.X, 0, 0)
			if d % (speed / 10) == 0 then
				print(d)
				wait()
			end
		end
	end,
}

while true do
	nRate = rate
	if nRate == 1 then
		nRate = 1 --math.random(-1, 1)
	end
	direction = direction * 1
	for i = 1, nRate do
		part:move()
	end
	wait()
end
