How to update gui for every player ingame and new people that join?

I’m trying to update a gui for all players in the server & for future people that join but I don’t know how to make it change for the new people that join after & my current code isn’t working to change it for everyone currently in the server.

game:GetService("ReplicatedStorage").CharChosen.OnServerEvent:Connect(function(player, CharacterFrame)
	for i, playerz in pairs(game:GetService("Players"):GetPlayers()) do
		for i, viewmodel in pairs(playerz.PlayerGui:WaitForChild("CharacterSelection"):WaitForChild("CharacterSelection"):WaitForChild("Characters"):GetChildren()) do
			if viewmodel:IsA("ViewportFrame") then
				if viewmodel:WaitForChild("CharName").Text == CharacterFrame.CharName.Text then
					viewmodel:Destroy()
				end
			end
		end
	end
end)

No errors so I don’t know what’s wrong with it. The code above was in a server script and the event was called by a localscript when someone selects a character (character customization) I am trying to make a character customization which only lets one player be each character

When it comes to updating GUI that should be done on the client. One way to solve this is a mix of remote events & remote functions or a folder in Replicated storage.

When a player joins, they either call a remote function to get list of available characters OR get the data from a folder containing data like that.

When a character is selected (and therefore locked) the client fires a remote event to the server, which then notes that the character is locked (meaning the folder will reflect this, and the remote function will not return that char). The server then fires all clients to let them know which character is now locked, alternatively with an updated list of which characters are available.

1 Like

Okay I’ll try that and see how it goes.

It still doesn’t work.
I made it fire the event again onto all clients once it is received on the server but for some reason it didn’t work.

Try updating in the client for current players, and for new players, maybe changing the frames ect in the starter gui by a server side script will work
(im not sure)

I tried that before and it didn’t seem to work.

show me the line where you fire the client event, also why are you looping through players on the client

oh lemme fix that then if it doesn’t work I’ll send

I did it but I keep getting this error, it exists and I don’t know why it says nil, I checked in the explorer and the value or textlabel is not nil.



image

Nevermind! It worked now!!! Thanks @Fimutsuu

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.