I was writing a script for my module, except it’s not working as intended. When the isAdmin(userId) function is run, it is supposed to look for userId in the Admins table, however returns nothing.
What makes this more confusing is that the script works perfectly fine when using usernames instead of player UserIds.
Script:
local adminChildren = script.Parent.Admins:GetChildren()
local admins = {}
for _, adminObj in pairs(adminChildren) do
table.insert(admins,tostring(adminObj.Name))
print("Added " ..adminObj.Name)
end
local function isAdmin(UserId)
print("Checking if " ..UserId .." is admin...")
if table.find(admins,UserId) then
print("Is admin!")
return "IsAdmin"
else
print("Not admin")
return false
end
end
When using UserIds, the script outputs:
Added 1448128761 - Server - Core:131
Checking if 1448128761 is admin... - Server - Core:143
Not admin - Server - Core:148
However, when using Usernames, the script outputs:
Added blortle - Server - Core:131
Checking if blortle is admin... - Server - Core:143
Is admin! - Server - Core:145
Any help is appreciated!
Edit: Would like to clarify, all children of the Admins folder are named with UserIds.