I have a gui in StarterGui, ScreenGui is named MyGui, I am attempting to whitelist it to where only certain players (Only me right now) can view the gui, but when I play the game on a different account/guest, the gui is still there. I have this script in the ScreenGui, but not a frame. I don't know if it's supposed to go there. (I'm kind've new to scripting)
Edit: The error is line 13 with gui: but I don't know what to change it to. (I deleted the code I was using before) and I also tested this as an alt. It still showed.
Players.Player1.PlayerGui.ScreenGui.LocalScript:13: attempt to index global 'gui' (a nil value)
local Whitelisted = {'DontBlinkDrWho'}
local player = game.Players.LocalPlayer
local Allowed = false
for _, PlayerName in ipairs(Whitelisted) do
if PlayerName == player.Name then
local gui = script.Parent
gui.Parent = player:WaitForChild('PlayerGui') -- No point to possibly find nil then retry w/ WaitForChild
Allowed = true
end
end
if not Allowed then gui:Destroy() end

1 comment
I edited stuff in the main post. (It isn't working still)