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 4 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:

01local Players = game:GetService("Players")
02 
03local AuthorizedUsers = {[525025404] = "Nitrolux200";}
04 
05local GUI = script.HostOnlyGui
06 
07Players.PlayerAdded:Connect(function(Player)
08    if (AuthorizedUsers[Player.UserId]) then
09        ---------------
10        GUI:Clone().Parent = Player.PlayerGui
11    end
12end)
0
set the ResetOnSpawn property of the gui to false k3du53 162 — 4y
0
^ simpler way to fix it than using characteradded Feelings_La 399 — 4y
0
Thanks that worked too! I'm using the resetonspawn thing because it's simpler, but the character added worked Nitrolux200 62 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 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,

01local Players = game:GetService("Players")
02 
03local AuthorizedUsers = {[525025404] = "Nitrolux200";}
04 
05local GUI = script.HostOnlyGui
06 
07Players.PlayerAdded:Connect(function(Player)
08 Player.CharacterAdded:Connect(function(Character)
09    if (AuthorizedUsers[Player.UserId]) then
10        ---------------
11        GUI:Clone().Parent = Player.PlayerGui
12end)
13    end
14end)

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 — 4y
Ad

Answer this question