My tweens will not run simultaneously!

I am making a script for tweens to run simultaneously. Currently they are running sequently. How do I make them run simultaneously? Attached video shows what they look like currently:

robloxapp-20240128-1655311.wmv (2.0 MB)

I understand that you cannot run muiltiple tweens on the same part, of the same property, I am currently not doing that.

My script uses Collection Service and the tweens follow waypoints forever!
Here is the server script:
This one runs perfectly!

-- Varibles
local Players = game:GetService("Players")
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local StartTween = ReplicatedStorage.StartTween

local Debouce = false

-- Main Function of finding and creating tweens
Players.PlayerAdded:Connect(function(Player)
	for _, TweenAbleObject in pairs(CollectionService:GetTagged("TweenAblePart")) do
		-- Creates Welds
		if TweenAbleObject:IsA("Model") then
			local Primary = TweenAbleObject.PrimaryPart

			for i, v in pairs(TweenAbleObject:GetChildren()) do
				if v:IsA("BasePart") and not Primary then
					local WeldConstraint = Instance.new("WeldConstraint", Primary)
					WeldConstraint.Name = v.Name.."Weld"
					WeldConstraint.Part0 = Primary
					WeldConstraint.Part1 = v
				end
				
				StartTween:FireClient(Player, TweenAbleObject)
			end
		end
	end
end)

Here is the next script which runs the tweens on client; this is the one I need help with!

-- Varibles
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local StartTween = ReplicatedStorage:WaitForChild("StartTween")

local Debouce = false

repeat task.wait(0.01) until game:IsLoaded()

local function Tween(TweenAbleObject)
	while wait(0.01) do
		if TweenAbleObject.Parent:FindFirstChild("WaypointFolder") then
			local WayPointFolder = TweenAbleObject.Parent:FindFirstChild("WaypointFolder")

			if WayPointFolder:IsA("Folder") then
				local Way = WayPointFolder:WaitForChild("Waypoint1")
				for i, Waypoint in pairs(WayPointFolder:GetChildren()) do
					if Debouce == false then
						Debouce = true
						local Tween = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0)
						local Waypoint = WayPointFolder:FindFirstChild("Waypoint"..i)
						local Goal = {}
						Goal.Position = Waypoint.Position

						local RealTween = TweenService:Create(TweenAbleObject.PrimaryPart, Tween, Goal)
						RealTween:Play()

						RealTween.Completed:Connect(function()
							Debouce = false
						end)

						repeat task.wait(0.01) until Debouce == false
					end
				end
			end
		end
	end
end

-- Main Function
StartTween.OnClientEvent:Connect(function(TweenAbleObject)
	coroutine.wrap(Tween)(TweenAbleObject)
end)

Thank you for your help!

You cannot play two tweens on the same property at the same time, this is intended behavior for TweenService, try a different approach, like using the same tween for the same properties, otherwise it won’t work.

Thank you for your quick response!

Sorry for being unclear in my description.

I understand that I cannot tween the same part’s property twice in two tweens. I am trying to make multiple instances move around the waypoints set up in a folder in the same model. I am using the Collection Service to find these parts, and I am trying to change multiple instance’s position value to the waypoints. My script is trying to move two parts at the same time, but it does not work.

I have tried using coroutine, and it may provide a solution but I am new to it.

Could you please help me further?

Thanks again for your swift response. :slight_smile:

You’re doing a lot of checks in the code, and it might just be that of those checks aren’t checking out, so add some print statements to see if all the code is running as intended.

It also looks like you’re setting the Debouce variable to true in the first iteration, I think you meant to put the debounce check and assignment before the loop?

Following that logic your code will only travel to the first way point.

Thank you again for you quick response :slight_smile:

I have tried the print statements and changed the debounce. All the print statements print and your debounce change did help a lot.

However the problem is still there, please look at the video to see the problem in its fullest:
robloxapp-20240128-1655311.wmv (2.0 MB)

I apoligize in advance for the bad quality and the fact that you have to download the video to see it.

Thank you for helping me!