GUI script won't work after the player dies, why is that?

Hello. I have been trying to make a team change GUI. The part where it changes the team works fine.

The issue is that I want the GUI to show up after the player dies. It does that with the current script, but only one time.

I have tried looking here, scripting helpers and watched some videos. I can’t seem to find anything that can help me.

I have a localscript and a script. Here is my localscript:

ImmigrantButton.MouseButton1Down:Connect(function(player)
	Gui.Enabled = false
	RE:FireServer(BrickColor.new(IT)) -- This doesn't matter.
	ResetGui:FireServer()
end)

And here is my script. This is the part that doesn’t work.

script.Parent.ResetGuiSpawn.OnServerEvent:Connect(function(Player)
    Player.CharacterAdded:Connect(function(Char)
        Char.Humanoid.Died:Connect(function()
            wait(5);
            Player.PlayerGui.ChangeTeamGui.Enabled = true;
        end)
    end)
end)

I am new to scripting, so any help would be very appreciated.

2 Likes

That’s a bit normal…
The problem is that the “server-side”, a script, is trying to control/modify player’s UI, and the UI (and everything that is in PlayerGui) may only get controlled/modified by the “client-side”, a local script (excluding some really rare things). What I mean is that the “server-side” will “see” UI.Enabled = true, and the client will “see” UI.Enabled = false.

I recommend you to use another RemoteEvent or the same RemoteEvent for this.

Thanks for the answer. This helped a lot! :+1: