Help with Tweening to All Clients

Hello Devs, I’m having an issue with firing a remote event which fires a tween from the server to all the clients in the game (Remote Event: Server to All clients). So, all the clients in the game will be seeing the tween and the server won’t have to deal with the tween. The problem is, the tween won’t play and I’m not sure why. I hope someone can help me.

- Here’s my code in the server script:

local RS = game:GetService(“ReplicatedStorage”)

local RemoteEvent = RS:WaitForChild(“RemoteEvent”)

local Ball = workspace:WaitForChild(“Part”)

RemoteEvent:FireAllClients()

- Here’s my code in a local script:
local RS = game:GetService(“ReplicatedStorage”)

local RemoteEvent = RS:WaitForChild(“RemoteEvent”)

local Ball = workspace:WaitForChild(“Part”)

local Players = game:GetService(“Players”)

local TweenService = game:GetService(“TweenService”)

local tweeningInformation = TweenInfo.new(

3,

Enum.EasingStyle.Linear,

Enum.EasingDirection.InOut,

-1,

true,

0

)

local Goal = {CFrame = CFrame.new(-70.184, 10.758, 0.526)}

RemoteEvent.OnClientEvent:Connect(function()

local Tween = TweenService:Create(Ball, tweeningInformation, Goal)

Tween:Play()

end)

try this clint script

local RS = game:GetService(“ReplicatedStorage”)

local RemoteEvent = RS:WaitForChild(“RemoteEvent”)

local Ball = workspace:WaitForChild(“Part”)

local Players = game:GetService(“Players”)

local TweenService = game:GetService(“TweenService”)

local tweeningInformation = TweenInfo.new(

3,

Enum.EasingStyle.Linear,

Enum.EasingDirection.InOut,

0,

true,

0

)

local Goal = {CFrame = CFrame.new(-70.184, 10.758, 0.526)}

RemoteEvent.OnClientEvent:Connect(function()

local Tween = TweenService:Create(Ball, tweeningInformation, Goal)

Tween:Play()

end)

Are you sure that remote event is getting handled by client script first?

Sorry, but what do you exactly mean by that?

I’ve done that, but is it safe to just tween in local script. I mean the only reason why I used a remote event in the first place is so every client can see it. Also, maybe to prevent the local script from being exploited.

no, you have done a mistake in local script, I have fixed it there…

you are giving -1 for repeat in your TweeInfo, that’s creating the issue and I have fixed it here Help with Tweening to All Clients - #2 by kittyPGR

Wait, I set it to -1 so the tween will keep playing (looping). I’m not sure, but is that a mistake?

Wait, so what can I do if I want to make the tween repeating?

you can use a loop…

I don’t think that’s gonna work

So I can run while loops forever with giving a wait and it’s not gonna crash my game right?

yep, use repeat until loop so that it won’t create any lags

A while loop can also do it I guess

like

repeat
   tween
until task.wait(time)

that would consume more memory, repeat loop is recommended over a while loop

Alright so this will run indefinitely and can I put the task.wait between the repeat and until?

you can do that also, or even this… up to you
and yes it will run infinitely

The code you fixed didn’t work, I don’t think the repeat count is the problem.

-1 sets tween to repeat infinitely, he had done it right. Using loops is a bad practice since data is the same and theres no interval between tweens. Im pretty sure the problem is that server sends tween data before any client loads in.

1 Like