The code I provided is an example, but it outlines pretty much exactly what you should do to get the result you’re gunning for. You want the clients to perform the tweens themselves, no? It’s why I added the “object”, “tweenInfo”, and “goal” variables in the parentheses on the LocalScript, it allows you to send the client information from the server.
Here, I’ll even change your script so that it works with the LocalScript I provided.
local ObstacleModule = {}
local TweenService = game:GetService("TweenService")
local ObstacleFolder = game.Workspace.ObstaclesFolder
-- Obstacle Parts
-- Moving Kill Brick parts
local MovePart = ObstacleFolder.MoveKillBrick["Kill-Brick"]
local MovePart_EndPos = ObstacleFolder.MoveKillBrick.EndPos
-- Spinning Kill Brick parts
local SpinningKillBrick = ObstacleFolder.SpinningKillBrick["Kill-Brick"]
local SpinningPartSupport = ObstacleFolder.SpinningKillBrick.Support
-- Hole In The Wall parts
local HITW_MovePart = ObstacleFolder.HoleInTheWall.MovingPart
local HITW_EndPos = ObstacleFolder.HoleInTheWall.EndPos
-- Standing Platform parts
local StandingParts = game.Workspace.Pillars.StandingPart:GetChildren()
-- Meteorites
local Meteorite = ObstacleFolder.Meteorite.Meteorite
local Meteorite_Pos1 = ObstacleFolder.Meteorite.Pos_1.Position
local Meteorite_Pos2 = ObstacleFolder.Meteorite.Pos_2.Position
local Meteorite_CloneFolder = ObstacleFolder.Meteorite.CloneMeteorite
-- Tween Info
local MovingPartTweenInfo = TweenInfo.new(4, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, 0, true)
local SpinningPartTweenInfo = TweenInfo.new(4, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, 0, false)
local HITW_MovingPartTweenInfo = TweenInfo.new(8, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, 0, true)
local StandingPartSizeTweenInfo = TweenInfo.new(2, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, 0, true)
local StandingPartRotateTweenInfo = TweenInfo.new(2, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, 0, true)
local StandingPartMoveTweenInfo = TweenInfo.new(4, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, 0, true)
local StandingPartSpinTweenInfo = TweenInfo.new(1, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, 0, true)
local PartSizeTweenInfo = TweenInfo.new(1, Enum.EasingStyle.Cubic,Enum.EasingDirection.InOut, 0, false)
local StandingPartColorTweenInfo = TweenInfo.new(1, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut, 0, true)
-- Properties
local MovingPartProp = {Position = MovePart_EndPos.Position}
local SpinningPartProp = {Orientation = Vector3.new(0, SpinningKillBrick.Orientation.Y + 180, 0)}
local HITW_MovingPartProp = {Position = HITW_EndPos.Position}
local MoveAndSpin_BigSizeProp = {Size = Vector3.new(1, 1, 100)}
local MoveAndSpin_SmallSizeProp = {Size = Vector3.new(1, 1, 1)}
local HITW_BigSizeProp = {Size = Vector3.new(4, 16, 100)}
local HITW_SmallSizeProp = {Size = Vector3.new(1, 1, 1)}
local StandingPartSmallSizeProp = {Size = Vector3.new(3, 1, 3)}
local StandingPartRotateProp = {Orientation = Vector3.new(0, 0, 60)}
local StandingPartSpinProp = { Orientation = Vector3.new(0, 360, 0) }
local StandingPartColorProp = { Color = Color3.new(0.101961, 0.101961, 0.101961)}
-- Tweens
-- Tweens Playing
local tweenObjectRemote = game.ReplicatedStorage.TweenObject
-- Reusable Functions
local function BigSize(partname, BigSizeProp)
partname.Transparency = 0
partname.CanTouch = true
tweenObjectRemote:FireAllClients(partname, PartSizeTweenInfo, BigSizeProp)
end
local function SmallSize(partname, SmallSizeProp)
tweenObjectRemote:FireAllClients(partname, PartSizeTweenInfo, SmallSizeProp)
task.wait(1)
partname.Transparency = 1
partname.CanTouch = false
end
-- Tween Functions
function ObstacleModule:MovingPartTween()
BigSize(MovePart, MoveAndSpin_BigSizeProp)
task.wait(1)
tweenObjectRemote:FireAllClients(MovePart, MovingPartTweenInfo, MovingPartProp)
task.wait(8)
SmallSize(MovePart, MoveAndSpin_SmallSizeProp)
end
function ObstacleModule:SpinningPartTween()
BigSize(SpinningKillBrick, MoveAndSpin_BigSizeProp)
SpinningPartSupport.Transparency = 0
task.wait(1)
tweenObjectRemote:FireAllClients(SpinningKillBrick, SpinningPartTweenInfo, SpinningPartProp)
task.wait(4)
SmallSize(SpinningKillBrick, MoveAndSpin_SmallSizeProp)
SpinningPartSupport.Transparency = 1
end
function ObstacleModule:HoleInTheWallTween()
BigSize(HITW_MovePart, HITW_BigSizeProp)
task.wait(1)
tweenObjectRemote:FireAllClients(HITW_MovePart, HITW_MovingPartTweenInfo, HITW_MovingPartProp)
task.wait(16)
SmallSize(HITW_MovePart, HITW_SmallSizeProp)
end
function ObstacleModule:StandingPartSize()
for index, value in pairs(StandingParts) do
task.spawn(function()
-- Tweens
tweenObjectRemote:FireAllClients(StandingParts[index], StandingPartColorTweenInfo, StandingPartColorProp)
tweenObjectRemote:FireAllClients(StandingParts[index], StandingPartSizeTweenInfo, StandingPartSmallSizeProp, 1.5) -- add delay parameter to function on client
end)
end
end
function ObstacleModule:StandingPartRotate()
for index, value in pairs(StandingParts) do
task.spawn(function()
-- Tweens
tweenObjectRemote:FireAllClients(StandingParts[index], StandingPartColorTweenInfo, StandingPartColorProp)
tweenObjectRemote:FireAllClients(StandingParts[index], StandingPartRotateTweenInfo, StandingPartRotateProp, 1.5)
end)
end
end
function ObstacleModule:StandingPartMove()
for index, value in pairs(StandingParts) do
task.spawn(function()
-- Tweens
tweenObjectRemote:FireAllClients(StandingParts[index], StandingPartColorTweenInfo, StandingPartColorProp)
tweenObjectRemote:FireAllClients(StandingParts[index], StandingPartMoveTweenInfo, { Position = StandingParts[index].Position + Vector3.new(10, 0, 0) }, 1.5)
end)
end
end
function ObstacleModule:StandingPartSpinAndMove()
for index, value in pairs(StandingParts) do
task.spawn(function()
-- Tweens
tweenObjectRemote:FireAllClients(StandingParts[index], StandingPartColorTweenInfo, StandingPartColorProp)
tweenObjectRemote:FireAllClients(StandingParts[index], StandingPartSpinTweenInfo, StandingPartSpinProp, 1)
tweenObjectRemote:FireAllClients(StandingParts[index], StandingPartSizeTweenInfo, StandingPartSmallSizeProp)
end)
end
end
function ObstacleModule:Meteorite()
for timer = 0, 15, 1 do
local RandomX = math.random(Meteorite_Pos1.X, Meteorite_Pos2.X)
local RandomZ = math.random(Meteorite_Pos1.Z, Meteorite_Pos2.Z)
local MeteoriteClone = Meteorite:Clone()
local Otherparts = MeteoriteClone:GetChildren()
MeteoriteClone.Position = Vector3.new(RandomX, Meteorite_Pos1.Y, RandomZ)
for index, parts in Otherparts do
if parts:IsA("Part") then
parts.Position = MeteoriteClone.Position
parts.Anchored = false
parts.CanCollide = false
parts.Transparency = 0
MeteoriteClone.Position = MeteoriteClone.Position
MeteoriteClone.Anchored = false
MeteoriteClone.CanCollide = false
MeteoriteClone.Transparency = 0
parts.Parent = MeteoriteClone
MeteoriteClone.Parent = Meteorite_CloneFolder
end
end
task.wait(0.5)
end
end
return ObstacleModule
Also, change the LocalScript to this:
local tweenService = game:GetService("TweenService")
local tweenObjectRemote = game.ReplicatedStorage.TweenObject
tweenObjectRemote.OnClientEvent:Connect(function(object, tweenInfo, goal, waitTime)
if (waitTime) then
task.wait(waitTime)
end
local tween = tweenService:Create(object, tweenInfo, goal)
tween:Play()
end)
It’ll allow you to wait before playing the tween by providing a fourth argument from the server.
This all should work just fine.