In my game, the Main Menu always comes back when the player dies. Any fixes?

Hi guys, this is my first post on the DevForum, so please bear with me if I have chosen the wrong category, etc.
So, this may seem like a drag to all of the highly-experienced developers, but yes, I am having trouble with making a Main Menu in my game. It is working fine, but it comes back again when I respawn, which I imagine would be a bit of a problem. Here is my code:

--The variables--
local playButton = script.Parent.PlayButton
local updateLogButton = script.Parent.UpdateLogButton
local quitGameButton = script.Parent.QuitGameButton
local mainFrame = script.Parent
local updateLogFrame = script.Parent.UpdateLog

--Scripts--
playButton.MouseButton1Click:Connect(function()
   mainFrame.Visible = false
end)

quitGameButton.MouseButton1Click:Connect(function()
   game.Players.LocalPlayer:Kick('Thanks for playing the game. I hope you come play again.')
end)

updateLogButton.MouseButton1Click:Connect(function()
    updateLogFrame.Visible = true 
end)

Donā€™t worry about the closing UpdateLog, because thatā€™s been handled. Here is an image of the branches:
UI Branch
In short, donā€™t change any code, but I would appreciate it if you were to add something that would stop it from coming back again when the client/player dies.
Thank you for reading, and I hope that someone can offer me a solution.

Hi, there is a property named ā€œResetOnSpawnā€ in a ā€œScreenGuiā€ (in your case named ā€˜UIā€™), try disabling that.

(ResetOnSpawn re clones the GUI to the PlayerGui when you respawn)

3 Likes

Disabling ResetOnSpawn just disables it from re cloning on spawn. Anything changed would remain the same as before the character spawned, if it was deleted or turned invisible it would stay that way. Any code would also remain running. The GUI wouldnā€™t be lost on dead, not sure what you mean with that.

Thanks @RedcommanderV2! Iā€™m really bad at some properties, but thank you!

2 Likes