I want to remove this ScreenGUI from selected Players but it does not work. The code is below.
01 | plr = script.Parent.Parent.Parent |
02 | admins = { "AdvancedCode" , "Player1" } |
03 |
04 | d = false |
05 |
06 | for i = 1 , #admins do |
07 | if plr.Name = = admins [ i ] then |
08 | script.Parent:remove() |
09 |
10 | if not d then |
11 | d = true |
12 | end |
13 | end |
14 | end |
All help is appreciated!
You should use a LocalScript - so you can index game.Players.LocalPlayer
to retrieve the client easily.
Code would look like this;
01 | local plr = game.Players.LocalPlayer --This is the player! |
02 | local admins = { "AdvancedCode" , "Player1" } |
03 | local d = false |
04 |
05 | for i = 1 , #admins do |
06 | if plr.Name = = admins [ i ] then |
07 | script.Parent:Destroy() --'remove' is deprecated. Use Destroy! |
08 | d = true ; |
09 | break --break the current loop |
10 | end |
11 | end |
Assuming the script's Parent is the gui, this should work.