Doesn't give me coins upon click

local levelUpBlocks = 100
local function onEnd(player)
part.Size = originalsize
local leaderstats = player:FindFirstChild(“leaderstats”)

if leaderstats then
	local luckyBlocksValue = leaderstats:FindFirstChild("🌈Lucky Blocks").Value
	local luckyBlocks = luckyBlocksValue
	local luckyBlocksEarned = luckyBlocksValue
	luckyBlocksEarned = luckyBlocksEarned + 1

	
	if luckyBlocksEarned > levelUpBlocks then
		local currentLevelValue = leaderstats:FindFirstChild("Level")
		local currentLevel = currentLevelValue and currentLevelValue.Value or 0
		luckyBlocksEarned = luckyBlocksEarned - levelUpBlocks
		levelUpBlocks = levelUpBlocks * 2

		if currentLevelValue then
			luckyBlocksEarned = luckyBlocksEarned + levelUpBlocks * currentLevel
			currentLevelValue.Value = currentLevel
			print("Current Level:", currentLevel)

	print("Lucky Blocks:", luckyBlocks, "Level Up Blocks:", levelUpBlocks)
end end end

I have tried fixing it for 1 week, i want when you reach a certain amount of coins, lets say 100, your level goes up by one and then your coins resets, then each level you get you earn 2x, you earn 1x coins now, so after 1 upgrade you earn 2x coins, and the next upgrade cost 2x HOW MANY ```` DO I NEED FOR IT TO BECOME LUA

1 Like

pls reply to me guys i need help

send us output and errors that happen when the click happens.

Try using `:WaitForChild(“leaderstats”) rather than :FindFirstChild(). I’m also pretty sure you’re missing an “end”,

3 if statements and 3 ends. i don’t think he’s missing anything. What he is missing however is the connection between this function and the click event.

No, I’m what I’m saying is that he has a function he’s defined on line 2, due to his terrible formatting it’s a bit difficult to read, but it doesn’t do anything. Did he mean to insert an end at the end of the script? He defined an empty function and never used it.

Line 2 is a variable, but speaking of line 2, why did he make another variable of it on line 3? I’m getting dumber reading this unless i get some context from OP. I assume OP used ChatGPT or copy and pasted this from Youtube. which is fine if you know what you’re doing.

Not missing an end, and waitforchild doesnt change anything still doesnt work