I want to remove this ScreenGUI from selected Players but it does not work. The code is below.
plr = script.Parent.Parent.Parent admins = {"AdvancedCode", "Player1"} d = false for i = 1, #admins do if plr.Name == admins[i] then script.Parent:remove() if not d then d = true end end 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;
local plr = game.Players.LocalPlayer --This is the player! local admins = {"AdvancedCode", "Player1"} local d = false for i = 1, #admins do if plr.Name == admins[i] then script.Parent:Destroy() --'remove' is deprecated. Use Destroy! d = true; break --break the current loop end end
Assuming the script's Parent is the gui, this should work.