Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

GUI that should only appear for admins when they join appears for everyone after death?

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.

1 comment

0

change line 22 to "if isAdmin(player) == true then" because if you don't write true then it means it's not nill

1 answer

✓ Accepted answer

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.

2 comments

0

Thank you so much!

0

No problem! I'm glad to hear it worked!!

This discussion is preserved as it was. New answers, comments, and votes are closed.