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

How would I incorporate math.floor/math.ceil into this script?

One of my game's upcoming boss fights is a tycoon-based mini-game where the players lose around 25% of their cash upon death.

The cash is shared by all players.

The issue here is that math is not one of my strong points, and I am unsure where to incorporate math.floor or math.ceil into my script in order to prevent decimals.

game.Players.PlayerAdded:connect (function(Player)
	local Money = game.workspace.Money	
	
	
	
	Player.CharacterAdded:connect(function()
		Player.Character.Humanoid.WalkSpeed = 25
		Player.Character.Humanoid.Died:connect(function()
			Money.Value = Money.Value - (Money.Value - (Money.Value*0.25))
		end)
	end)
	end)

Any help would be greatly appreciated, because it gets quite bothersome when you have a 10 degit decimal at the top of your screen.

1 answer

✓ Accepted answer

Here's the script rewritten to avoid decimals

game.Players.PlayerAdded:connect (function(Player)
    local Money = game.workspace.Money

    Player.CharacterAdded:connect(function()
        Player.Character.Humanoid.WalkSpeed = 25
        Player.Character.Humanoid.Died:connect(function()
            Money.Value = math.floor(Money.Value * 0.75) -- Find the lowest common integer of 75% of the new value.
        end)
    end)
end)

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