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

Instead of taking 500, it takes the whole of how to fix?

Asked by 5 years ago

Hey, I made a script that exchanges currency from strength to rebirth and instead of taking 500 strength, it takes all the collected strenght please a help

game.ReplicatedStorage.Rebirth.OnServerEvent:connect(function(player)
    if player.leaderstats.strength.Value >= 500 then -- strength needed to rebirth
        player.leaderstats.rebirths.Value = player.leaderstats.rebirths.Value +1
        player.leaderstats.strength.Value = 0
    end
end)

1 answer

Log in to vote
1
Answered by
CPF2 406 Moderation Voter
5 years ago
game.ReplicatedStorage.Rebirth.OnServerEvent:connect(function(player)
    if player.leaderstats.strength.Value >= 500 then -- strength needed to rebirth
        player.leaderstats.rebirths.Value = player.leaderstats.rebirths.Value +1
        player.leaderstats.strength.Value = player.leaderstats.strength.Value - 500
    end
end)

You were setting it to zero instead of subtracting from the current value, here is a fixed version

Ad

Answer this question