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

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

Asked by 3 years ago

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)
0
set the ResetOnSpawn property of the gui to false k3du53 162 — 3y
0
^ simpler way to fix it than using characteradded Feelings_La 399 — 3y
0
Thanks that worked too! I'm using the resetonspawn thing because it's simpler, but the character added worked Nitrolux200 62 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

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

0
another solution would be to set the ResetOnSpawn property of the gui to false k3du53 162 — 3y
Ad

Answer this question