Help needed with a moving cart system

Hi, I’ve recently been working on a game and I had an idea for some sort of cart


So I asked my friend if he could script it for me as I can’t really script, he agreed and scripted everything and I truly am thankful. But I’ve got an issue where it keeps reversing, I’ve asked if he could help me but I don’t want to cause any stress.
Here’s the script:

local ts = game:GetService(“TweenService”)

local completed = false

while wait(45) do
completed = not completed

if completed == true then
	ts:Create(script.Parent, TweenInfo.new(45, Enum.EasingStyle.Linear), {Position = Vector3.new(168.952, 111.903, 926.994)}):Play()
else
	ts:Create(script.Parent, TweenInfo.new(45, Enum.EasingStyle.Linear), {Position = Vector3.new(169.877, 112.828, -243.575)}):Play()
end

end

Does it reverse every 45 seconds? If so, I think it’s probably because it’s looping every 45 seconds to reverse back and forth.

Do you just want it to wait 45 seconds and then move it to the location but never go back? If so, this is all you really need

local ts = game:GetService("TweenService")

wait(45)

ts:Create(script.Parent, TweenInfo.new(45, Enum.EasingStyle.Linear), {Position = Vector3.new(168.952, 111.903, 926.994)}):Play()

It’s supposed to reverse, I put 45 to test it, if it really is the problem I might time it.

I’m not sure what you’re trying to do exactly, could you describe what you want to do with the moving cart?


A cart with a seat that goes from one island to another is what I’m trying to do.
It moves forward and backwards etc

By always reverses do you mean how as soon as it goes to where it wants, it goes back to where it was originally?

Yes, the wheels move and it just reverses slowly back to it’s origin.

Perhaps do this?

local ts = game:GetService(“TweenService”)

local completed = false

local info = TweenInfo.new(45, Enum.EasingStyle.Linear)

while wait(45) do
	completed = not completed
	if completed == true then
		local tween = ts:Create(script.Parent, info, {Position = Vector3.new(168.952, 111.903, 926.994)})
		tween:Play()
		tween.Completed:Wait()
	else
		local tween = ts:Create(script.Parent, info, {Position = Vector3.new(169.877, 112.828, -243.575)})
		tween:Play()
		tween.Completed:Wait()
	end	
end

So it waits for it reach its destination and then wait 45 seconds

I appreciate your help but it doesn’t move. And I thought I might as well try figure it myself if I had made the game.