Owner only gui works, but when owner dies, stops working

Heres what im tryna do. i’m tryna make a owner only gui, it works but, when the owner dies, his gui dissappears. please help, heres the script:

game.Players.PlayerAdded:Connect(function(player)

if player.Name == “CrownedH20” then
game.Players.CrownedH20.PlayerGui:WaitForChild(“OWNERONLY”).Frame.Visible = true
end

end)

That’s because this event only fires when the player initially joins in a server.

Ideally, handle this on the client (in the GUI) directly via a LocalScript, and use code like…

if game.Players.LocalPlayer.Name == "CrownedH20" then
script.Parent:WaitForChild("Frame").Visible = true
end

This would be more reliable as well.

2 Likes

CharacterAdded might work as well. But on the other hand, GUI is locally.

1 Like

Yeah. I’ve always heard it’s good practice to let the client update their PlayerGui.

1 Like

it says in output “Attempted to index nil with ‘Name’” line 1

Did you make it a LocalScript and put it into your GUI directly?

oh nvm, it works! thank you!!!

1 Like

Now mark the solution so whenever someone has the same problem, they can find your post.

You can also set ResetOnSpawm to false.

EDIT: I don’t realize this has already been solved. Please mark it as such so someone else doesn’t make the same mistake.

1 Like