(Note: I know this is not the right category, but I cannot post in discussions yet.)
So I am trying making an intermission that all clients can see and the text for the intermission is the same for each client. I am using a remote event for this, and doing Server → all Clients. Is this efficient? If not, is there a better way?
Also, I am not asking for an whole script, I just tips and suggestions on how I should do this efficiently and functioning.
I already gave u the script…
It would be easiest to store the state in replicated storage, but you can use the RemoteEvents to send the state each time it changes as well. You should probably make sure to also fetch the state from server when client initializes since it will be state-less until next change.
So you are saying, fire the remote event when the text changes? Ex: Script.Parent.Text = “Hello welcome” to “Loading map…”?
I would send the start of intermission via RemoteEvent, including the number in seconds. Then let the client count down (in case player has poor connection it still counts down normal). And when it is done, wait for the RemoteEvent fired again.
This allows you to handle the countdown client side, which is useful as the server does not really need to know remaining time.
Server keeps check of state, when state changes it notifies client which then changes the text.
Server → Client → Change text
So like when the countdown ends, and the text changes to example, “120 seconds left” fire another remote event?
Server → Client : Hey, Intermission is 120s.
(Client counts down)
(120s later)
Server → Client : For me, 120s are over. I am starting the new round. Tell the player that.
Just extremely simplified, but I hope it helps
For for the countdowns would i do them in local script or a server script?
Local, as they are Client-Side handled.
You’ve asked this already in a previous post
@crywink 's Answer is what you’re looking for
You have a serverscript, that will fire all clients and all the changes for the player occur on the client.
So would I fire the remote event in local script, and receive it in a server script?
No… you Fire it in a Server Script then you receive it in a Local Script.
ServerScript → Remote Event → Clients
You have your server script, Which will get the information, then pass it out.
local CurrentTime = tick()
while true do
local TimeElapsed = math.floor(tick() - CurrentTime)
RemoteEvent:FireAllClients(TimeElapsed)
wait(1)
end
That is your server script, then your local script should be
RemoteEvent.OnClientEvent:Connect(function(TimeElapsed)
TextLabel.Text = tostring(TimeElapsed)
end)
That defeats the purpose, all you need to do is fire a remote once for every player (RemoteEvent:FireAllClients()
) and on each client, display the numbers.
You’ll need to keep it bearably synced on the server, so after the interval, from the server tell all clients to stop counting down for the intermission.
Read my reply on your other post here: Remote Event is not Firing! - #14 by un1ND3X