GUI problem with CharacterAutoLoads disabled

(i am aware there are posts like this, but they arent related to my exact problem)

For a gamemode in my game, Im making so players that join mid gamemode wont spawn in, but rather have spectating UI. To do this, i implemented some custom respawn system code with the help of another user.
When you get the spectating ui, None of your other UI is there, So what i did was make so it just brings all the UI from StarterGui into your playerGui, This works fine, but when you respawn, the UI doesnt go away (despite having “ResetonSpawn” enabled) This is really frustrating and blocking further development, Any help is greatly appreciated.

Also, not so sure what to do about GUIs that have ResetOnSpawn disabled, certain ones have that, and i dont want there to be duplicated GUIs.

Script for getting all the UI into the players gui (not important, just got this from a different post)

for _, gui in ipairs(game.StarterGui:GetChildren()) do
	gui:Clone().Parent = plr:FindFirstChild("PlayerGui")
end
2 Likes

This is because StarterGui and StarterPlayerScripts do not run when the player joins, it waits for the first character to be loaded.

I place my client code under ReplicatedFirst, which will run before the player spawns in. This should solve your problem.

3 Likes

I’m sorry, i don’t think i understand.

I don’t have any client code related to this, The gui is placed in the character via server script, that detects when a player joins, It inserts the gui just fine, but im wondering why it keeps it in.

Ahh, That makes more sense now.

If i were to place the gui in the player via local script, then it wouldnt work since certain server scripts try to get the UI, if it isnt there for the server, those UIs wont work at all.

2 Likes

What do you mean by this? Or in other words, why can’t you just use the code in a local script under ReplicatedFirst?

1 Like

Certain server scripts modify every player’s UI sometimes (this way is fine, i really dont wanna use a remote event everytime)

Because then the server would just not know they exist, Plus, I dont think this could solve my issue as i dont think it’ll go away just if i do it in the client.

2 Likes

Use remotes. You are replicating the GUI to the server when it shouldn’t need to do that in the first place. Remotes will take less bandwidth on the server, and loading through ReplicatedFirst means that the GUI will not be shown on the server.

It’s a horrible practice to manipulate GUI on the server, it’s better to get out of that habit now rather than later.

Besides, replicated less on the server means lower ping for all players.

2 Likes

Makes sense, the reason i was doing it in the first place was because its really really annoying having to FireAllClients() on a remote event just because i want to make one frame visible.

Alright, i will try all that you have said, and come back with the results (Might take a bit)

3 Likes