Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Gui not showing up on Player.CharacterAdded Event?

Asked by 2 years ago

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

Log in to vote
0
Answered by
Wayyllon 170
2 years ago
Edited 2 years ago

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.

0
Thanks, I'll see if this works! DriBowser 55 — 2y
0
Yep, it works. Thank you so much! DriBowser 55 — 2y
0
glad to help. Wayyllon 170 — 2y
Ad

Answer this question