Why does this if statement break the local script?

im trying to make a inventory system, and to prevent ui from duplicating if a person has multiple amounts of an item, i added an extra if statement(comment), but that if statement also breaks it. how come?

InventoryRE.OnClientEvent:Connect(function(Item)
	for _, v in pairs(Player.Inventory:GetChildren()) do
		if v.Name == Item.Name then
			if v.Value <= 0 or v.Value == 0 then -- runs fine without, breaks with
				local ItemUI = ReplicatedStorage.ItemUI:Clone()
				ItemUI.Parent = InventoryFrame

				ItemUI.Counter.Text = v.Value
				ItemUI.Text = v.Name
				ItemUI.ItemName.Value = v.Name
			end
		end
	end
end)

You dont need the or v.Value == 0, you included that in <=0.

I did the “or” because both both variations broke it

turns out the issue was the 0s, the “v.Value” updated to 1 before the if statement

1 Like