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

How can i solve this math problem in scripting inside my game, it s weird ?

So, it`s a dumb question, but how can i make ( if the player has 10 views, then he gets 1 money per second), and add the multiplier for example if the player has 20 views then he will get 2 money and so on, idk how to do the math, i already have the loop with wait(1) second and all, but idk how to make the math.

Folder.AddMoney.OnServerEvent:connect(function(plr)
	if plr.leaderstats.Views.Value >= 10 then
		plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + ???
	end
end)

2 answers

Here is a solution for anyone checking it out later on, or OP if they want to use this solution

Folder.AddMoney.OnServerEvent:connect(function(plr)
	local increase = math.Floor(plr.leaderstats.Views.Value/10)
	plr.leaderstats.Money.Value = plr.leaderstats.Money.Value  + increase	
end

math.Floor basically rounds down the number. Because of this, we get the views (e.g. 25), divide by 10 (10 views = $1/s). This will give us 2.5. OP wants it as the integer, so we use math.Floor, which makes it equal 2!

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