--[[

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

