Heya. I have a GUI that should appear for admins when they join, however, it also appears for non-admins when they die. Now, there's nothing special in the GUI, but I'd still like to fix this.
local admins = { "Player1"; "Player2"; "Player3"; "Player4" } local function isAdmin(player) for _, v in pairs(admins) do if v == player.Name then return true end end return false end local Players = game:GetService("Players") local AW = game.StarterGui.AdminWelcome.Gradient Players.PlayerAdded:Connect(function(player) if isAdmin(player) then AW.Visible = true else AW.Visible = false end end)
Any help is appreciated.
The problem
You are writing if isAdmin(player) then
which means if isAdmin(player)
is not equal to nil then it will go ahead.
Solution
You must write if isAdmin(player) == true then
which is being precise to what the result is.
local admins = { "Player1"; "Player2"; "Player3"; "Player4" } local function isAdmin(player) for _, v in pairs(admins) do if v == player.Name then return true end end return false end local Players = game:GetService("Players") local AW = game.StarterGui.AdminWelcome.Gradient Players.PlayerAdded:Connect(function(player) if isAdmin(player) == true then --//This is the change AW.Visible = true else AW.Visible = false end end)
I'm not sure if this helped but I hope it did! Make sure to accept the answer if it worked perfectly. Any problems reply to this answer and I'll try to change it.