Attempt to compare nil <= number | DATASTORE 2

These few line of codes give me an error when I try to check the datastore value.

attempt to compare nil <= number

--// Update maxExperience
	experience.Changed:Connect(function() 
		print(experienceData:Get()) -- Prints 50
		repeat 
			if experienceData:Get() >= maxExperienceData:Get() then
				levelData:Increment(1) -- Increases level by 1
				maxExperienceData:Set(levelData:Get() * (1000 + math.random(0, 200) * level)) --Creates random Max XP basesd on level
				--maxExperience.Value = maxExperienceData:Get()
				end
		until experienceData:Get() / maxExperienceData:Get() > 1
	end)
	
	
	experienceData:Set(50)

It is this line specifically

if experienceData:Get() >= maxExperienceData:Get() then

Does printing maxExperienceData:Get() work?

1 Like

That’s the wrong operator, you provided the wrong code snippet.


Yes it prints 50 commented in the script

maxExperienceData:Get() must be returning nil.

You are absolutely correct I printed it and it prints nil