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

why wouldn't the script reconized the player names?

Asked by 10 years ago
local access = {"players's name","players's name"}
local gamepassid = 00
local Player = game.Players.LocalPlayer
if game:GetService("MarketplaceService"):PlayerOwnsAsset(Player, gamepassid) or Player.Name == access then
script.Parent.Visible = true
else
script.Parent.Select.Disabled = true
script.Parent.Visible = false
end

Did i do something wrong on the first line?

1 answer

Log in to vote
2
Answered by 10 years ago
local access = {"players's name","players's name"}
local gamepassid = 00
local Player = game.Players.LocalPlayer
local authorized = false

for i = 1, #access do --this checks if the local player's name is equal to any of the names in the table
    if access[i] == Player.Name then
        authorized = true --set authorized to true if the name is in the table
        break
    end
end

if game:GetService("MarketplaceService"):PlayerOwnsAsset(Player, gamepassid) or authorized then
    script.Parent.Visible = true
else
    script.Parent.Select.Disabled = true
    script.Parent.Visible = false
end
Ad

Answer this question