hello. my buying script for my game doesnt work and there are no errors. im going to add comments in the script so u can understand what some stuff mean

-- cost, amountadd, and currency are variables thati carried from my local script that fires the	event
script.Bought.OnServerEvent:Connect(function(player, cost, amountadd, currency)
	if currency.Value == 1 then -- if currency is 1 it will use rebirth tokens
		local tokens = player.leaderstats["Rebirth Tokens"]
		if tokens.Value >= cost.Value then
			tokens.Value = tokens.Value -cost.Value
			player.TrashLvl = amountadd -- set it to amount ad
		else
			if currency.Value == 0 then -- if currency is 0 use cash currency
				local cash = player.leaderstats.Cash
				if cash.Value >= cost.Value then
					cash.Value = cash.Value -cost.Value
					player.TrashLvl = amountadd -- set it to amount add
				end
			end
		end
	end
end)

1 comment

0

Try using <= instead of == if the number can be larger than 1