Whats wrong with this even the userid is right

even my userid is right it doesnt visible the gui

local player = game.Players.LocalPlayer

wait(2.5) -- Budgets

local Id = {

1496821609;

2531652900;

1618636024;

1067355832;

1067355832;

747867145;

}

for i, v in pairs(Id) do

print(player.UserId.." ".. v)

if player.UserId == v then

script.Parent.Visible = true

else

script.Parent.Visible = false

end

wait()

end

You never break the loop. So if it finds your ID, it will make it visible…but the loop continues. So if the other IDs don’t match, it switches back to not visible. You need to either break your loop or just use a dictionary table instead.

script.Parent.Visible = false
for i,v in ipairs(Id) do
    if player.UserId == v then
        script.Parent.Visible = true
        break
    end
end

Here’s the dictionary method:

local Id = {
    [1496821609] = true;
    [2531652900] = true;
    [1618636024] = true;
    -- etc.
}

script.Parent.Visible = if Id[player.UserId] then true else false
3 Likes
wait(2.5) -- Budgets

local Id = {

1496821609;

2531652900;

1618636024;

1067355832;

1067355832;

747867145;

}

for e,player in pairs(game.Players:GetPlayers() do
for i, v in pairs(Id) do

print(player.UserId.." ".. v)

if player.UserId == v then

script.Parent.Visible = true

else

script.Parent.Visible = false

end

wait()

end
end
local player = game.Players.LocalPlayer
task.wait(2.5) -- Budgets

local Id = {
	1496821609;
	2531652900;
	1618636024;
	1067355832;
	1067355832;
	747867145;
}

for i, v in pairs(Id) do
	if player.UserId == v then
		script.Parent.Visible = true
		break
	else
		script.Parent.Visible = false
	end
	task.wait()
end

You were just missing a break statement which breaks the loop if it is found that your ID matches one from the table.

1 Like