Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a button disappear for a certain player?

Asked by 8 years ago

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

Log in to vote
0
Answered by 8 years ago

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)
0
Sorry, but when I pasted it in, there is an error (Expected Identifier, got '['). starlebVerse 685 — 8y
0
Which line? TheHospitalDev 1134 — 8y
0
wait i was editing the code in a normal script... Silly me! :D starlebVerse 685 — 8y
0
it didnt work :( starlebVerse 685 — 8y
0
:/ I have no clue then, sorry.. TheHospitalDev 1134 — 8y
Ad

Answer this question