I want to make the HQButton visible only to those whose userid is mentioned in the code, but it is not working as it should.
If the properties of the button is set to true, then it shows the button to all the players and does not care if the ID is mentioned in code or not.
If the properties of the button is set to false, then it doesn’t show the button even if the player’s name is mentioned in the code.
Code-
local player = game.Players.LocalPlayer
local HQButton = script.Parent
local DepartmentFrame = HQButton.Parent
local ChooseFrame = DepartmentFrame.Parent
local EROIStaffSystemUI = ChooseFrame.Parent
local HQLoginFrame = EROIStaffSystemUI:WaitForChild("HQLoginFrame")
local allowedUserIds = {
1806979894, -- Abhaas
}
local function isAllowedPlayer()
for _, userId in ipairs(allowedUserIds) do
if player.UserId == userId then
return true
end
end
return false
end
if isAllowedPlayer() then
HQButton.Visible = true
else
HQButton.Visible = false
end
local function onHQButtonClicked()
ChooseFrame.Visible = false
HQLoginFrame.Visible = true
end
HQButton.MouseButton1Click:Connect(onHQButtonClicked)
UI structure-
The HQButton visibility is set to false