Reset on Spawn Bug

I was having a bug where the play button wouldn’t work after changing the character (original post) but I was able to fix it by setting the ResetOnSpawn Property to true but when the player dies it shows the gui again. I’ve tried setting the resetonspawn to false again but it doesn’t make a difference. I want the GUI to not show when the player dies and not show until the end of the round or until the player goes to the home screen.

local rm = game.ReplicatedStorage.PlayerClickedPlayButton



script.Parent.Activated:Connect(function()
	rm:FireServer()
	
	for i, v in script.Parent.Parent.Parent.Parent["Main Menu"]:GetDescendants() do
		if v:IsA("Frame") then
			v.Visible = false
			game.Players.LocalPlayer.PlayerGui["Main Menu"].ResetOnSpawn = false
		elseif v:IsA("TextButton") then
			v.Visible = false
			game.Players.LocalPlayer.PlayerGui["Main Menu"].ResetOnSpawn = false
		elseif v:IsA("ImageButton") then
			v.Visible = false
			game.Players.LocalPlayer.PlayerGui["Main Menu"].ResetOnSpawn = false
		end 
	end
	
	game.Players.LocalPlayer.PlayerGui.StopWatch.Frame.Visible = true
	game.Players.LocalPlayer.PlayerGui["Game Condition"].Frame.Visible = true
end)

It looks like you are doing a lot of confusing workarounds so I can’t really give you the exact code for your use-case without actually seeing the full setup.

But one solution could be using a script outside of the Gui (PlayerScripts) that enables and disables the Gui based on when you want the Gui to appear.

Well the resetonspawn just kinda refreshes the page because before changing the character the gui is still referencing the old character but you are changed into the new character while the script is referencing the old one which no longer exists. And basically im trying to disable the refreshing when the player is actually in the game which is after they press the play button but its not working like its supposed to.

Yeah I don’t really understand what your character switching thing is. But the way ResetOnSpawn works is anytime your Character is reloaded (Respawned) your Gui also reloads which means anything in its script that saved past info as variables, or had specific changes to Gui objects is reset as if it didn’t happen.

Again, I do not really understand what you are trying to do for your use-case but if you’re having issues related to the Gui not appearing how you want it to my best suggestion would be handling it with an outside script that determines when user has the Gui, when it’s enabled, etc and maybe leaving ResetOnSpawn turned off.

1 Like