deb = false
price = 5000
cps = 500
increase = 100
function onClicked(playerWhoClicked)

    if playerWhoClicked.Character:FindFirstChild("Humanoid") and deb == false then
        deb = true
        local playerWhoClicked = game.Players:GetPlayerFromCharacter(playerWhoClicked.Character)
        if playerWhoClicked.leaderstats.Clicks.Value >= price then
        playerWhoClicked.leaderstats.Clicks.Value = playerWhoClicked.leaderstats.Clicks.Value - price
        price = price + increase
        playerWhoClicked.leaderstats.Cps.Value = playerWhoClicked.leaderstats.Cps.Value + cps
deb = false
            while wait(1) do
                playerWhoClicked.leaderstats.Clicks.Value = playerWhoClicked.leaderstats.Clicks.Value + cps
            end
        end
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

i was testing this, and i kept getting more and more clicks and cps, which is what is supposed to happen. but then it stopped. i knew i had enough clicks to buy the upgrade (this script upgrades the amount of clicks i get) but it wouldnt buy. i have multiple of these upgrades, each with different prices and cps and such. those ones worked. but 2 of them stopped. why does this script randmoly shut off sometimes?

5 comments

0

trying inputting a print and see if it's even working in the area. like putting it on line 10. print("still going")

0

it breaks before line 15

0

before line 11

0

i think its the deb part that keeps breaking

0

game.Players:GetPlayerFromCharacter(playerWhoClicked.Character) 10 if playerWhoClicked.leaderstats.Clicks.Value >= price tIs what I think is the problem