Module script not being recognized

I made a module script with a user ID and I made another script which gets the creator ID.

local WhitelistedUsers = require(script.Parent.WhitelistModule)

if game.CreatorType == Enum.CreatorType.User and game.CreatorId == table.find(WhitelistedUsers, game.CreatorId) then
	print("Whitelisted")
else
	print("Not whitelisted")
end

Module Script

local Users = {
	1783349062 -- User 1 [Kryptoscythe]
	
	
}

return Users

But it keeps printing “Not whitelisted” even though it is my creator ID in the module and I am the game creator.

Try changing the script to this:

local WhitelistedUsers = require(script.Parent.WhitelistModule)

if game.CreatorType == Enum.CreatorType.User and table.find(WhitelistedUsers, game.CreatorId) then
	print("Whitelisted")
else
	print("Not whitelisted")
end

Also, CreatorId will be the actual user ID in the roblox game client.

2 Likes
local WhitelistedUsers = require(script.Parent.WhitelistModule).Users

if game.CreatorType == Enum.CreatorType.User and table.find(WhitelistedUsers, game.CreatorId) then
	print("Whitelisted")
else
	print("Not whitelisted")
end


You made a typo on the first line.

local WhitelistedUsers = require(script.Parent.WhitelistModule).Users

Instead of checking through Modulescript.Users you checked the Modulescript.


Like @MyUsernames_This said, table.find is sufficient in this if statement.

if game.CreatorType == Enum.CreatorType.User and table.find(WhitelistedUsers, game.CreatorId) then

table.find will return true so the extra game.CreatorId == isn’t needed.


If this solved your problem, please mark this reply as the solution.

Remove this, table.find is sufficient