Hi, I've been looking a while and can't find the answer for this. So basically, I'm trying to fix a bug in my game which makes the guis disappear when the player respawns. So what I've been trying to do is make it so the gui re-appears, but it won't. The thing is though, the print message will send even after the gui should show. I've been trying to fix this for ages but it won't work. Help would be appreciated!
Here is the local script inside starter Gui:
local Player = game.Players.LocalPlayer -- I was just testing with the first button which is for bugs. local Char = Player.Character or Player.CharacterAdded:Wait() local died = false local Bugs = script.Parent.Parent:WaitForChild("Bugs") local Bugsbutton = Bugs:WaitForChild("TextButton") Char:WaitForChild("Humanoid").Died:Connect(function() died = true print("Dead") end) Player.CharacterAdded:Connect(function(Char) print("Respawned") if died == true then Bugsbutton.Visible = true -- Won't appear print("Bugs Visible") -- Still prints end died = false end)
Roblox has a dumb, outdated behavior, where GUI's will replicate again and again unless you change some property, in the Screen Gui holding all of this stuff, you need to toggle "ResetOnSpawn" to false.
Useful links:
https://developer.roblox.com/en-us/api-reference/property/LayerCollector/ResetOnSpawn
Im not sure if this is the correct answer, if it isn't, sorry.