Level requirement doesn't work like it's supposed to

I’m literally losing my mind right now. I’m making a game where you could choose a role/job. Some of these jobs are level-locked, so you gotta be a certain level to play as this role/job, and some jobs have limits, so only a certain amount of players can play on that role.

Now, either I suck at math, or something is wrong with my code here.
Level >= 100 should mean that the player must be at least level 100 for this code to work, yet it does not. It works when I write <= 100, but that means ANYBODY can play as this role, no matter the level.

Yes, the datastore and the levels are just fine. I’m above level 100 and it still prints out the player doesn’t fit the requirement thing.

I’ve tried to write a different approach, but I figured this is the best way, and the easiest. If this was to work, I’d just add an event and fire it, and then change the player’s team via server script, if all of these requirements are met. (I’m gonna add this bit once I fix my issue.)

Code is not finished, this is just me debugging, and I’ve ran into this issue, so I’m rewritting everything.

presidency.MouseButton1Up:Connect(function()
	local color = BrickColor.new("Deep blue")
	if level >= 100 then
		
		print("player fits level req")
		
		local p = 0
		
		for _,v in pairs(game.Players:GetPlayers()) do
			
			if v.TeamColor == color then
				p = p + 1
			end
		end
		print("there is "..p.. " playes on that team")
	elseif level < 100 then
		print("plr doesnt fit the lvl req")
		
	end
end)

presidency.MouseButton1Up:Connect(function()
	local color = BrickColor.new("Deep blue")
print(level)
	if level >= 100 then
		
		print("player fits level req")
		
		local p = 0
		
		for _,v in pairs(game.Players:GetPlayers()) do
			
			if v.TeamColor == color then
				p = p + 1
			end
		end
		print("there is "..p.. " playes on that team")
	elseif level < 100 then
		print("plr doesnt fit the lvl req")
		
	end
end)

i addd a print level thing at the top, tell me what it prints

prints 0 for some reason, but my level is 150??? okay, my leaderstats broke. Nice

Where is level defined?
char char char limit

Okay, i’ve managed to fix it. Apparently, i cant do:

local level = leaderstats.Level.Value

ive removed the .Value from the variable and added them to the if statements and it works. But, thank you guys anyway

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