My value is equal to another but still returns false

I want to make a easy way to give players chat tags but when I use a if statement to check if the requirement for the tag is equal to the player’s UserId, it says its false for some reason even though when I print out the values, they’re both the same.

local Tags = require(script.Tags)

function GetTags(player)
	for _, tag in pairs(Tags) do
		local requirementsArgs = string.split(tag.Requirement, ":")
		if requirementsArgs[1] == "Id" then
			if requirementsArgs[2] == player.UserId then -- Checks if the requirement and the player user id is the same
				return tag
			else
				print("bruh")
			end
		end

	end
end

The module script which stores all of the tags is like this

{
	Name = "Developer",
	Requirement = "Id:1210019099",
	TagColor = Color3.fromRGB(255, 85, 0),
	MessageColor = Color3.fromRGB(255, 170, 0)
}

Any help is apprechiated.

2 Likes

Is there anything on the output? Have you tried printing?

It just prints “bruh” which is what it prints if the values arent equal

You need to convert that requirementsArgs[2] string to a number otherwise it will always return false:

if tonumber(requirementsArgs[2]) == player.UserId then
2 Likes

It worked! Thank you my man, this really hurt my brain trying to figure it out.