Attempt to compare nil <= number | Weird error

image

I’m getting this weird error

Line 39 - 45:

	local leaderstats = Instance.new("Folder")
	leaderstats.Parent = Player
	leaderstats.Name = "leaderstats"

	local Candy = Instance.new("NumberValue")
	Candy.Parent = leaderstats
	Candy.Name = "Candy"

Line 115 - 121:

	--GetPropertyChangedSignal
	Candy:GetPropertyChangedSignal("Value"):Connect(function()
		if Candy.Value >= maximumBackpackCapacity then --Error line
			Candy.Value = maximumBackpackCapacity
			Argument:FireClient(Player, "ChangeDataValues", maximumBackpackCapacity)
		end
	end)

For information, “maximumBackpackCapacity” is a number variable which changes if you own a certain BoolValue. (Check under for more information)

			if Backpack1.Value == true then
				maximumBackpackCapacity = 10
				if Backpack2.Value == true then
					maximumBackpackCapacity = 100
					if Backpack3.Value == true then
						maximumBackpackCapacity = 1000
						if Backpack4.Value == true then
							maximumBackpackCapacity = 10000
						end
					end
				end
			end

There is already a datastore implemented which uses Tables

Any help is appreciated, thanks

Oh, and the “Argument” variable is a RemoteEvent in ReplicatedStorage.

is the ‘maximumBackpackCapacity’ set after or before the :GetPropertyChangedSignal()?

It’s set when trying to get the Player’s data. In this case, it’s Before the :GetPropertyChangedSignal().

Add this line to the first code block you posted (Line 39-45)

	local maximumBackpackCapacity

Also, if Backpack1’s Value isn’t true, it won’t check for Backpack2, and some goes to Backpack2, Backpack3, etc., this should fix it too

			if Backpack1.Value == true then
				maximumBackpackCapacity = 10
			end

			if Backpack2.Value == true then
				maximumBackpackCapacity = 100
			end

			if Backpack3.Value == true then
				maximumBackpackCapacity = 1000
			end

			if Backpack4.Value == true then
				maximumBackpackCapacity = 10000
			end
1 Like

Oh, found the issue. It was because for some reason the Backpack1 variable got changed to FALSE. Without that being “true”, there’s no maximumBackpackCapacity.

This did help me out though!

Thank you!

1 Like