Confusing bug breaks script

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.

1 Like

It’s probably because you are comparing number to string. Maybe trying casting the userId to String or vice versa?

3 Likes

Lol this was it, thanks. Can’t believe I forgot that :man_facepalming:

(i did try to run tostring() before on the object name, but that obviously wouldn’t fix it)

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.