you can use a loop…
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?
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.
Wait, so I suppose the client needs to handle the remote event first?
I did this,
local RS = game:GetService(“ReplicatedStorage”)
local RemoteEvent = RS:WaitForChild(“RemoteEvent”)
local Players = game:GetService(“Players”)
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Wait()
RemoteEvent:FireAllClients()
end)
and it’s fixed, but is there like any other solution? I still don’t get it which side should handle the remote event first.
Wait, I realized that the tween is not playing at the same time for one player and another. The object that is being tweened is not moving at the same position.
Is there any way to fix this? help
Its honestly easier to simply tween on the server.
The client side is unique for each player, so you can set different tweens for each one if you wanted to.
Also, if you fire all clients every time a character is added, this will attempt to run your Tween function on each client again. It will probably resolve the conflicts itself, but
But like, isn’t it laggy to tween on the server. I heard that it’s better to tween on the client.
If the server runs the Tween the clients will get updated by the server. If the client is receiving the update later due to lag, it may look less smooth or ‘laggy’.
If you run the Tween on the client, but the client gets the remote event later than others due to lag it will run out of sync, but be smoother (assuming the client’s machine can handle everything).
So I guess it depends what the Tween is controlling and how that fits in with the rest of your game.
So is it okay if I play the tween in a local script without firing remote events?
Yes. It might be out of sync with other players’ as they see it (so might not be good if you are relying on the part for hit detection etc) but if its just visuals it should be fine to run the tween on the client and you won’t need to send unneccessary events to all clients.
You could of course change the script to fire to the specific client when that player joins. ie
RemoteEvent:FireClient(Player)
It really depends how much control you want over it from the server.