local players = {"user1","user2","user3","user4","user5"}
if game.Players.LocalPlayer.Name == #players then
script.Parent.Enabled = true
else
script.Parent:Destroy()
end
Above is the script I am using to give the player the gui. (the gui is in startergui) However, no matter what I do the gui is destroyed. How can I stop this? My name is in the table and I don’t know how to fix this.
EDIT: It also gets disabled no matter what if i replace destroy with enabled.
So, I think your problem here is that you aren’t checking for the player name’s through this script, just the number of items in your table. Try something like this:
local players = {"user1","user2","user3","user4","user5"}
for I,v in pairs(players) do
if game.Players.LocalPlayer.Name == v then
script.Parent.Enabled = true
else
script.Parent:Destroy()
end
end
local players = {"user1","user2","user3","user4","user5"}
if table.find(players, game.Players.LocalPlayer.Name) then
script.Parent.Enabled = true
else
script.Parent:Destroy()
end
local playerIds = {1, 2, 3}
if table.find(playerIds, game.Players.LocalPlayer.UserId) then
script.Parent.Enabled = true
else
script.Parent:Destroy()
end
UserIds would be better as players can change their username.