I've put the GUIs in the StarterGui since having them spawned via script into the PlayerGui caused them to be deleted when the player respawned.
However, the GUIs don't function as intended after the player dies. I've asked the function in question to fire when the player clicks on the GUI. It works as intended until the player dies and respawns. That is when the GUI will stop connecting the function when it is clicked.
Here's a script that emulates this behaviour:
function ExampleFunction() N = Instance.new("Message", game.Workspace) N.Text = "Message" wait(3) N:remove() end game.Players.LocalPlayer.PlayerGui.Example.ExampleButton.MouseButton1Down:connect(ExampleFunction)
The function "ExampleFunction()" will stop being fired after the player resets/respawns, though the button remains. There are no error messages. Please help me.