Hello Developers!
I’m currently making an admin script, which is almost finished, but when I wanted to make an :unadmin command I ran into this problem; I want to check if the player is an admin, which worked before but because I’m using a different method now it doesn’t work anymore. I also want to remove the player’s UserId from the table whenever someone types :unadmin {name}, which also doesn’t work. I hope this is enough info, let me know if you need some clarification!
Useful variables:
local lowerMsg = string.lower(msg)
local splittedString = string.split(lowerMsg, " ")
local command = splittedString[1]
local target = splittedString[2]
local ModuleScripts = script.Parent.Parent:WaitForChild("ModuleScripts")
local admins = require(ModuleScripts:WaitForChild("Administration"))
Check if the player is admin:
local function playerIsAdmin(player)
for i, v in pairs(admins) do
print(v) -- Prints the correct value
if v == player.UserId then -- Somehow false??
return true
end
end
end
Remove from admin table:
elseif command == cmdPrefix.."unadmin" then
local playerToDemote = checkForPlayer(target)
if playerToDemote ~= nil then
for i, v in pairs(admins) do
if v == playerToDemote.UserId then
table.remove(admins, i)
printAdminList()
end
end
end
Admins Table: (ModuleScript)
local Administration = {
"67792130"; -- Rowan_Scripts
"133492854"; -- Iovehxrtss
"604873370"; -- LorenzoNL2580
}
return Administration