Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer
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

This discussion is preserved as it was. New answers, comments, and votes are closed.