How would I go about making a Boosting/Bonus System?

Hello fellow developers! I have a question I need some answers on… Boosting/Bonus System! I’ll be listing the questions I have down below:

A general overview of what I’m trying to achieve: So, if you have played bee swarm simulator, you should be familiar with their “Timed boosting system” for say, For 15 minutes, you get a certain boost where you collect 15% more pollen in this specific field, and so on.

My Questions:

  1. How would I wrap my head around such a system? I have tried creating one but my efforts are in vain (Shown down below)

  2. How would I set a timer for boosts? Like you get it for 15 minutes only and if you leave the game and come back 10 minutes later you will have 5 minutes left. I know this uses os.time and datastores but I seriously cannot understand how to use os.time. Every attempt I’ve tried always fails…

I’ll be listing the code I have tried for Problem 1:

Problem 1 (My take on the Boosting system))

game.Players.PlayerAdded:Connect(function(Player) -- Server script when player joins
	--# Player Boost Test
	local Folder2 = Instance.new("Folder",Player)  -- Data is saved on Datastore2
	Folder2.Name = "BoostsFile"
	local ChopBoost = Instance.new("IntValue",Folder2)
	ChopBoost.Name = "ChopBoost"
	ChopBoost.Value = 1
	local ConversionBoost = Instance.new("IntValue",Folder2)
	ConversionBoost.Name = "ConversionBoost"
	ConversionBoost.Value = 1
end)

I realised when I was making this that I do not know how to mess around with percentages and I only can make up some multipliers.

This is a server script that runs in a knife when the knife chops an apple, it detects for any boosts.

if player:WaitForChild("BoostsFile"):FindFirstChild("ChopBoost").Value > 1 then
				local BoostedAmount = Strength.Value * player:WaitForChild("BoostsFile"):FindFirstChild("ChopBoost").Value
				pt.Text = "+"..BoostedAmount
				print("Added +"..BoostedAmount.." To Player!")
			else
				local UnboostedAmount = Strength.Value
				pt.Text = "+"..UnboostedAmount
				player:WaitForChild("Stats").Apple.Value = player:WaitForChild("Stats").Apple.Value + UnboostedAmount
				print("No Boosts Active! Added +"..UnboostedAmount.." To Player!")
			end

I really really hope I can get the problems resolved with your help. Thank you ALL!

~ I also have another post I need help on a Questing system you can check out!

1 Like

So for the example with bee swarm, you can use a Value. If the Player X bought it then gives him the Value with a ServerScript that count the time since he got it. Then when you gather the pollen, if the player has X Value then give AmountOfPollens * Percentages to this players. Do you get my idea?

Now for the question about datastore i can’t help you since i use DataStore2. Also i wouldn’t do os.time. What i would do is saving the Value and updating it when it changed. If you just change the Value when the player leave the server, you could give a IntValue with a child as a ServerScript. The IntValue would contains the Value of the Saved value insude datastore

Well, it can sort of be earned and not bought so like I just want to give a boost to the player but I don’t know how. Perhaps you could provide some code examples too?

1 Like

I could for sure gives an example for the bought thingy. But for the DataStore, i wouldn’t be able to give an example as you need to learn how to use DataStore or DataStore2 first. I would suggest you to take a look at AlvinBlox, on youtube. He does some good tutorials and some of them are related to both DataStore and DataStore2

1 Like

No need. I have already stated that I am using Datastore 2 to handle the values

Alright so since you use DS2, it will be easy to insert the IntValue

Yup, all I need is an example of the “boosting” code as I need to understand it before I set a timer for it

As example:
Once you clicked the part that gives the boost, it would change your IntValue inside the DS2. Once your Value inside DS2 has been changed, and if the Value ~= 0, then clone that Value, add a script which do Value -= 1 every second, parent the script to the cloned Value (which should Disabled set to false) and then parent the ClonedValue to the character. Do you got my idea?

Yes I do, but could you elaborate on how the boosting part actually works? With all the percentages and all

The boosting part would contains a ClickDetector (because this is how i would do that but you can do it with something else).

local click = script.Parent
click.MouseClick:Connect(function(plr)
--Find the root of your Value inside your DS2
end)

When you learned how to use DS2, you should have added a line for every Value, once they changed, it does save. So at this part of the BoostValue you could do:

local clone = BoostValue:Clone()
clone.Parent = character

local Counter = script:WaitForChild("ReduceValue") --It is a script which will just do Value -= 1 every second
Counter.Parent = clone
Counter.Disabled = false

Um I don’t think you get what I am trying to say, I’m trying to ask for an example for what you mentioned over here

You would play around with touch event or anything else to check if the player is gathering pollen. Once you got it, just do something like

local PollenCount = workspace:FindFirstChild(plr.Name):WaitForChild("PollenValue") --IntValue or NumberValue
local Collect = 1 --the amount of pollen you should get when you have no boost

if workspace:FindFirstChild(plr.Name):FindFirstChild("BoostValue") then
   PollenCount += (Collect + (Collect * workspace:FindFirstChild(plr.Name):FindFirstChild("BoostValue").Value))
end

Hi I am still unable to achieve the results I want.

While I cannot help you with the rest of your problem I can teach you something very helpful and useful about percentages that will help with all other games.

Percentages are usually written in games like this: “15%” or “25%”

But the thing about a percentage is that it’s actually just a fancy fraction. So “15%” is actually just 15/100 and “25%” is 25/100.
So technically all you need to do is take the player’s stat and add the player’s stat times the fraction, like this:

playerStat = playerStat + ( playerStat * (15/100) )

While the above DOES work, this is actually a little messy to look at and you can simplify a bit in a few different ways.

One such way is like this:

playerStat = playerStat*(115/100) 
-- this way you're multiplying by 115% which is a 15% increase of the original number.

Another thing you can do is just simplify the fraction, even if you can’t do this in your head you could use a calculator:

playerStat = playerStat*1.15

Or if you wanted the bonus to be able to change you could use a variable like so:

percent = 15
playerStat = playerStat*(1+(percent/100))

To give a really concrete example you can see in your head, think about the following:
The player collects 3 pollen each time. You want to give the player a x2 pollen boost. That’s 100% MORE than they’re normally getting.
So you do the following:

pollen = 3
percent = 100
pollen = pollen*(1+percent/100) 
-- the above is the same as the below --
pollen = 3*(1+100/100) --or--
pollen = 3*(2) --or--
pollen = 6 -- which is 100% MORE than 3

I hope this helps demystify percentages a bit, they’re actually super simple.

1 Like