Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How i can set max grow on Player? My script not work...

Asked by 5 years ago

Hi guys, i have one problem on this script:

replicatedStorage.Simulator.Test.OnServerEvent:Connect(function(player)

    if not remoteData:FindFirstChild(player.Name) then return "NoFolder" end

    local debounce = remoteData[player.Name].Debounce

    if not debounce.Value then

        debounce.Value = true

        if player.leaderstats.Power.Value < 3000 then

            player.leaderstats.Power.Value = player.leaderstats.Power.Value + 1 * (player.leaderstats.Rebirths.Value + 1)

            player.leaderstats.Money.Value = player.leaderstats.Money.Value + math.random(1,4) * (player.leaderstats.Rebirths.Value + 1)

        elseif player.leaderstats.Power.Value >= 3000 then

            player.leaderstats.Power.Value = player.leaderstats.Power.Value + 0

            player.leaderstats.Money.Value = player.leaderstats.Money.Value + math.random(1,4) * (player.leaderstats.Rebirths.Value + 1)

        wait(cooldown)

        debounce.Value = false
        else
        end

    end

end)

Works only the first time, in the second "punch" i not receive power and money.

Sorry for bad english

1 answer

Log in to vote
1
Answered by
sleazel 1287 Moderation Voter
5 years ago

It would seem that you reset your debounce inside the elseif section. Debounce should be reset outside the if elseif else end section.

replicatedStorage.Simulator.Test.OnServerEvent:Connect(function(player)

    if not remoteData:FindFirstChild(player.Name) then return "NoFolder" end

    local debounce = remoteData[player.Name].Debounce

    if not debounce.Value then

        debounce.Value = true

        if player.leaderstats.Power.Value < 3000 then

            player.leaderstats.Power.Value = player.leaderstats.Power.Value + 1 * (player.leaderstats.Rebirths.Value + 1)

            player.leaderstats.Money.Value = player.leaderstats.Money.Value + math.random(1,4) * (player.leaderstats.Rebirths.Value + 1)

        elseif player.leaderstats.Power.Value >= 3000 then

            player.leaderstats.Power.Value = player.leaderstats.Power.Value + 0 --this line is not necessary, but you may want to leave it for clarity

            player.leaderstats.Money.Value = player.leaderstats.Money.Value + math.random(1,4) * (player.leaderstats.Rebirths.Value + 1)

        else --this else is not needed

        end

        --move this two lines
        wait(cooldown)
            debounce.Value = false

    end

end)

Have a nice scripting session!

Ad

Answer this question