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

Players with perms in script to view Gui can view Gui but Gui disappears after they die. Help pls?

So a person named "Ziffix" scripted me this script were only certain players listed in the table can view the Gui. The problem is that the people that have permission to view the Gui, when they die the Gui disappears and they need to rejoin for it to appear once again which will be annoying. Can someone help me and make it so it's there forever for the people who have permission to view the Gui?

Here is the script:

local Players = game:GetService("Players")

local AuthorizedUsers = {[525025404] = "Nitrolux200";} 

local GUI = script.HostOnlyGui

Players.PlayerAdded:Connect(function(Player)
	if (AuthorizedUsers[Player.UserId]) then
		---------------
		GUI:Clone().Parent = Player.PlayerGui
	end
end)

3 comments

0

set the ResetOnSpawn property of the gui to false

0

^ simpler way to fix it than using characteradded

0

Thanks that worked too! I'm using the resetonspawn thing because it's simpler, but the character added worked

1 answer

✓ Accepted answer

you see, the gui clones and adds in each time player joins the game, but you said the issue was that if the player joins the game and resets, the gui won’t reclone. This is when you need to use characteradded. This event fires when player’s character spawns or respawn (https://developer.roblox.com/en-us/api-reference/event/Player/CharacterAdded)

so what you need to do is,

local Players = game:GetService("Players")

local AuthorizedUsers = {[525025404] = "Nitrolux200";} 

local GUI = script.HostOnlyGui

Players.PlayerAdded:Connect(function(Player)
 Player.CharacterAdded:Connect(function(Character)
    if (AuthorizedUsers[Player.UserId]) then
        ---------------
        GUI:Clone().Parent = Player.PlayerGui
end)
    end
end)

If there’s anything wrong. Tell me, because I’m on mobile right now

1 comment

0

another solution would be to set the ResetOnSpawn property of the gui to false

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