Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Gui not showing up on Player.CharacterAdded Event?

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)

1 answer

✓ Accepted answer

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.

3 comments

0

Thanks, I'll see if this works!

0

Yep, it works. Thank you so much!

0

glad to help.

This discussion is preserved as it was. New answers, comments, and votes are closed.