Attempt to compare number <= nil

Button.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local Character = hit.Parent
		local Player = Players:GetPlayerFromCharacter(Character)
		
		print(tostring(Character.Name))
		
		local NewOwner = tostring(Owner.Value)
		
		if Character.Name == NewOwner and Player:FindFirstChild("leaderstats"):FindFirstChild("Cash") then
			
			local cash = Player:FindFirstChild("leaderstats"):FindFirstChild("Cash")
			local numCash = tonumber(cash.Value)
			
			if numCash >= Price.Value then -- Error here
				Button.CanTouch = false
				Button.CanQuery = false
				
				Purchases.Dropper1:Destroy()
				print("Destroyed Item")
			end
		end
	end
end)

In output it says: attempt to compare number <= nil, and I don’t know what to do with that information.

Any help is appreciated!

2 Likes

Means that Price.Value doesnt exist. Trying to compare nothing with a number, its probably numCash or Price.Value

1 Like

Price.Value is nil, try checking if it isn’t before, like:

if Price.Value == nil then return end

Could you show us the whole script and the Explorer if you can?

1 Like

Bruh, in another script a folder gets destroyed, and Price.Value is in it, sorry. :confused:

But it’s fixed now, thank you!

1 Like

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