Help with getting values

Hello. I am trying to give a player a certain item when they reach a leaderstat int value. Here is the
script. It’s a local script in a GUI in startguis. The player is grabbing the local player of the game. In the leaderstats, I have one thousand. It should give me the level give clearance. I know the events are working because I was messing with that earlier. Is it not grabbing the values?

while true do
	local clearance = 0
	if plr.leaderstats.XP.Value == NumberRange.new(0,9) then
		clearance = 1
		eventClearance:FireServer(clearance)
	elseif plr.leaderstats.XP.Value == NumberRange.new(400,5000) then
		clearance = 5
		eventClearance:FireServer(clearance)
	end
	wait(5)
end

I don’t think you can compare a number to a NumberRange. They are two completely different data types. Second, for something like XP, it should be done on the server, not on the client, obviously for security reasons. Finally, you should only check the experience when the value of the XP changes, and not constantly every 5 seconds.

Well then how do I find if the players XP is between two numbers?

Here:

if PlayerXP >= 9 or PlayerXP <=9 then
print("Test.")
end
1 Like
local clearance = 0
if plr.leaderstats.XP.Value >= 0 and plr.leaderstats.XP.Value <= 9 then
	clearance = 1
	eventClearance:FireServer(clearance)
elseif plr.leaderstats.XP.Value >= 400 and plr.leaderstats.XP.Value <= 5000 then
	clearance = 5
	eventClearance:FireServer(clearance)
end
1 Like

Shouldn’t it be and instead of or, since that would mean that every value that’s either below or above those numbers would be true?

Yes sorry about that, I’ll fix it right now, but you get the idea.

1 Like