Ep 44. 0 Clicks Fix

During this episode we began creating and implementing our first developer products, which was Click packages. In order to prevent these packages from becoming unrewarding as the player progressed through our game, we wanted to increase the amount of clicks the player would receive based on their amount of rebirths. Unfortunately, we forgot to account for the player not having any rebirths, which resulted in them receiving 0 coins from these packages.

Solution

Update the CalculateClicksProduct function inside of the ReplicatedStorage/Configs/Shop module script with the following code.

ReplicatedStorage/Config/Shop.lua
function Shop.CalculateClicksProduct(index: number, data)
	local productConfig = Shop.Products.Clicks[index]
	local amount = productConfig.Amount
	
	local rebirths = data.Rebirths
	if rebirths == 0 then
		rebirths = 1
	end
	amount *= rebirths
	
	return amount
end
Contents