I am trying to make an admin system with an option to automatically give the owner’s friends admin, I have tried to search on the wiki about get friend async but everything I have tried isn’t working.
local admins = {
{
ID = 1578920035,
Rank = 5
},
}
local friendCommands = true
local friendCommandRank = 4
game.Players.PlayerAdded:Connect(function(player)
if friendCommands == true then
for i, friendUserId in pairs(game.Players:GetFriendsAsync(player.UserId):GetCurrentPage().UserId) do
table.insert(admins, {ID = player.UserId, Rank = friendCommandRank})
end
end
end)
When a player joins the game, you could use Player:IsFriendsWith() to check if the player is friends with the owner. I’m pretty sure it returns a boollean, so you can do
if player:IsFriendsWith(00000) then
—[[table insert stuff]]
I’m on mobile, formatting is kinda hard on mobile.
This might be unnecessary, but maybe you could add an index to the table every time a player joins regardless of whether or not they’re friends with the owner, and remove the index if the player is not friends with the owner.
game.Players.PlayerAdded:Connect(function(player)
if friendCommands == true then
if player:IsFriendsWith(game.CreatorId) then
table.insert(admins, {ID = player.UserId, Rank = friendCommandRank})
end
end
end)
If the game.CreatorID of the game is a group id, then IsFriendsWith won’t work because obviously groups can’t have friends.
Perhaps you could just make a variable called “creatorID” or something like that and leave it up to you/the person using that script to configure the creator ID.
local creatorID = 0000000
if player:IsFriendsWith(creatorID) then
—stuff
end