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.
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)