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!