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

How to make a button disappear for a certain player?

I am making a shop (button) which will be invisible for certain players who enter the game. However, when I was testing it (I was one of the certain players), the button was still there on my screen. I have no idea what mistakes occured in the script. Can someone teach me how to fix it, please?

Below is my script:

--Should the script be a local script or normal script?

local button = script.Parent
local player = game.Players.LocalPlayer

game.Players.PlayerAdded:connect(function()
	local admin = ( --The players who have one of the UserIds below should not see the button.
		player.UserId == 90568658 or 
		player.UserId == 76204529
	)
	if admin then
		script.Parent.Visible = false
	else
		script.Parent.Visible = true
	end	
end)

1 answer

Try. (P.S. Local)

local button = script.Parent
local player = game.Players.LocalPlayer

game.Players.PlayerAdded:connect(function()
    local admin = {--The players who have one of the UserIds below should not see the button.
     	["90568658"] = true;
        ["76204529"] = true
   }
    if player.UserID[admin] then
        script.Parent.Visible = false
    else
        script.Parent.Visible = true
    end 
end)

5 comments

0

Sorry, but when I pasted it in, there is an error (Expected Identifier, got '[').

0

Which line?

0

wait i was editing the code in a normal script... Silly me! :D

0

it didnt work :(

0

:/ I have no clue then, sorry..

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