How to change script process based on UserID in ModuleScript

Hello devforum,

Today my issue regards reading a pre-inserted UserID from a ModuleScript and comparing it with the LocalPlayer’s ID to change how the script acts.

This is to be used as part of a tower I’m currently developing for the up-and-coming game Speedwell, the intent is for the script to use a different path when a Content Creator is playing the tower as a small easter egg which I think would be really funny.

Currently, the IDs are stored in a ModuleScript (as mentioned), here is the layout for said script:

local YTModule = {}

YTModule.IDs = {
0,
0, -- Just image these being UserIDs
0
}

return YTModule

and here is my method for reading it in the LocalScript which needs to read it:

local YTIDs = YTModule.IDS
local YT = nil
function YTInfoGet()
	for i, v in YTIDs do
		if i == plr.UserId then
			local YT = true
		else
			YT = false
		end
	end
end

Unfortunately, I’m not really a person who uses for statements that much, and I don’t know how to navigate them that well.
Apparently, doing it this way, doesn’t work.

If anyone can help, please reply below.

1 Like

“i” means index and “v” means value, so you’re getting the index of the userid in the table
So just try changing i == plr.UserId into v == plr.UserId, and also remove the local from local YT = true because that makes a new variable

Yep, that solved it, thanks for your help!

1 Like

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