UI is not visible for all players at the same time

What I want to achieve:
I want my UI to look the exact same for all players.

My problem:
The UI is not the same for all users. For example, if one player joins the script would run and the UI would appear however, whenever a second user joins, the UI isn’t showing at the same time. So the person who joined first is ahead of the second player who joined. If you don’t understand just reply with what you don’t understand.

What solutions have I tried:
I have tried remote events but I couldn’t get it to work.

The code I have currently (I know, I know, the code is very messy):

while true do
for i,player in pairs(game.Players:GetPlayers()) do
    player.PlayerGui.ObbyEvent.Enabled = true
	
	wait(1) --Event starts 1 second after user loads into server for first time.
	script.Parent.Cooldown.TextLabel.Script.Disabled = false
	script.Parent.Visible = true
	script.Parent:TweenPosition(UDim2.new(0.345, 0,0.017, 0))
	print("Obby Event Has Begun!")
	wait(12) --Event UI is visible for 10 seconds.
	script.Parent:TweenPosition(UDim2.new(0.345, 0,-1, 0))	
	wait(1)
	script.Parent.Cooldown.TextLabel.Script.Disabled = true
	script.Parent.Visible = false
	wait(300) --Event starts every 5 minutes, not including when user loads in.
	end
	end

Please do not reply with the script exactly! I want to learn how to do things myself. Please just reply with what I need and maybe provide a link to what I need.

3 Likes

You can just track when the player is joined and loaded then clone the gui and parent it to the Player gui?

But the UI would not appear every 5 minutes for every user in the game, because maybe they joined after or before.

Is it a Localscript ? Gui may not work correctly if you are using Script.

Do everything matchmaking related on a server script and have it change a value in ReplicatedStorage, whenever the value is changed, a localscript should capture the change and update the gui accordingly.

You could have a bool value in workspace and if its true then make sure the ui’s are visible, otherwise keep it invisible.

Yes, I was thinking of doing something like that. Maybe I could change an intvalue in replicated storage or something. :+1:

Thanks, I had thoughts of doing it that way. Thanks for confirming it! :grinning:

Would you know if I had to clone the gui in playergui or can I just enable the gui in startergui?

You could have a remote event to FireAllClients from the server. Then in a local script you could receive the event and show your UI.

1 Like

Cheers, I would have to loop the FireAllClient though surely? Wouldn’t this stress the server out? And also, would I store the UI inside of StarterGui or would I have to clone the UI inside of PlayerGui? Thanks.

Use FireAllClients() yes, you cannot change everyone’s UI on the server side. You CAN change a player’s UI technically speaking on the server side but I don’t recommend doing it that way. So technically it is possible to change a player’s UI using the player gui in the playerobject on the server to a extent but I suggest you use :FireAllClients() in that situation.

1 Like

I believe I’ve just complete what you said however, when I load into the game, the server wont load. Are the scripts somehow in timeout?

Hmm, ran the game in studio and works fine, no script exhaustion in the output or anything… Weird.

Sorry for taking so long to get back to you!

The reason for that being is the server will always load before the client. So when you fireallclients on the first time on the server, nothing will happen until the next go around. You should make a function and in that function loop through all the players and just in general what should happen every 300 seconds. This way you can easily call that function.

Do you want the UI to show whenever a player joins then in the loop? Cause I’m still a bit confused on what you mean the server not loading,.

So I have made the UI appear every 5 minutes however, the wait(300) begins for only that player, and not everyone in the server. So say one user joined, the wait(300) would begin then, another user joins two minutes later after the first user, the second person who joined would be behind because they joined 2 minutes later so, the first person is two minutes ahead of the second user.

No you don’t need to loop through FireAllClient’s. FireAllClient fires to all connected clients in this case everyone. As for recieving the UI, and showing it all clients, inside of “StarterGui”, you can store your Ui. From there you can simply enable the UI, and your relevant things in the local script.

An example would be…
– ServerScript

game.ReplicatedStorage.Remote_Event:FireAllClients()

– Local

game.ReplicatedStorage.Remote_Event.OnClientEvent:Connect(function()

script.Parent.Visible = true
-- The rest of your code
end)