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

How do I make booster for a simulator game?

Asked by 5 years ago

I want my simulator game to only have one item to click but I need boosters like clothes or pets to increase the stats faster. What should I put in the script that it's in the booster to add more points when clicking?

0
why are you even making a simulator game LoganboyInCO 150 — 5y
0
lol MinuhaYT 19 — 5y
0
Simulators are for losers. Don't make simulators. Plus this is not a request site. Proven to be Too Broad. ArtyomAL3X 12 — 5y
0
ArtyomAL3X True Freddan2006YT 88 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

i dont rlly encourage u to make simulators but ohwell

TL;DR: First, you can create a pet (or an accessory) with its initial data which will give information on which elements should the pet boost, the multiplier and specify the owner (in this case, you). Then, create a server-side Script that manages your points, supporting the boosters by connecting a function that calculates the final sum of points with the multiplier to a RemoteEvent so the client will be able to send the request to the server to have their points added. (Well, storing values in the Server is pretty much one of the safe ways to prevent cheaters, but not the best.)

To demonstrate this, we will first create a pet. I'll just call this pet FlyingBanana. Then, add it in a storage for pets that can be replicated to both Server and Client (which is ReplicatedStorage). This is the directory of the storage: game.ReplicatedStorage.PetStorage

Alright, so, now we'll add some information of how this pet will behave. But what's his owner? Well, you can equip pets, correct? That means, you can create a table of equipped pets using a LocalScript. For example:

--LocalScript
local equippedPets = {
    "FlyingBanana",
    "CactusCat",
    --etc
}

--When equipping, add the name of the pet to the table above.
--Upon unequipping, remove the unequipped pet from the table above.

Now, the pet is sooooo cute that it will increase your income by its own adorableness! But in ROBLOX, it won't be noticed until you making a ModuleScript for the pets so they can act as "messiahs" for your financial status! (well, not quite lol)

Let's start by creating a ModuleScript named "PetInfo" with the content as following:

--PetInfo ModuleScript // Ancestor: ServerStorage
local pet_info = { --A dictionary of pets and their benefits
    ["FlyingBanana"] = {
        Multiplier = 2 --Why not 1? Well, 1*1=2, does it not correct?
    }
    -- You can add more pets here
}

return pet_info --Return the information of the pets

It'll be placed in ServerStorage!

Alright! Now we have enough information. To make your booster works, simply follow these instructions:

Step 1: Create a RemoteEvent in ReplicatedStorage so as to set the final points (after the process of boosting points) when a player taps their mouse (or on the screen, but in this case, it's a mouse). We'll call it "MouseClicked"

Step 2: Create a script that manages the RemoteEvent when it is fired by the client.

--Server-side script in ServerScriptService
--This is just a reference. You can do these your way.
local remoteevent = game.ReplicatedStorage.MouseClicked
local serverStorage = game.ServerStorage

local petInfo = require(serverStorage.PetInfo) --Requires PetInfo for info about pets
--You can change this to itemInfo since we have both accessories and pets as boosters

local pointsPerClick = 2 --Really low, right? We will have a process here.

local debouncePlr = {}

local function onMouseClicked(plr, equippedItems) --equippedItems // either boosters or just pure cosmetics
    local debouncing = false
    table.foreach(debouncePlr, function(key, val) --Check if the player is in debounce
        if val == plr then
            debouncing = true
        end
    end)
    if debouncing then
        return --Stops the function
    end
    --Add player to debounce to prevent them from spamming and stuff
    table.insert(debouncePlr, plr)

    --My method on boosting points
    local plrPoints = game.ServerStorage.PlayerPoints["plr"..plr.UserId]
    --PlayerPoints is a folder. We're getting the NumberValue containing the points of the player.
    --Now we can start the process.
    local multiplier = 0 --Not gonna multiply pointsPerClick by zero lol

    for index, thing in pairs(equippedItems) do
        --Get the information about the booster.
        local inf = petInfo[thing] -- "thing" must be a string.
        --Access the dictionary and therefore add up the multiplier.
        if inf.Multiplier > 1 then
            multiplier = multiplier + inf.Multiplier
        end
    end

    --Now. We will do the thing.
    if multiplier < 1 then
        multiplier = 1 --I told ya I won't multiply that by zero
    end
    plrPoints.Value = plrPoints.Value + pointsPerClick*multiplier

    --Points are added. Now exclude player from table.
    for i = #debouncePlr, 1, -1 do
        if debouncePlr[i] == plr then
            table.remove(debouncePlr, i)
        end
    end

    --NOTE: To get the player points from the client, simply tell the server to throw a remote event to get the points once the value changed.
    --      If the value is in ReplicatedStorage, no remotes needed, but more vulnerable to be manipulated.
    --      But don't worry, ReplicatedStorage is also safe too, just not as safe as ServerStorage.
    --      I'm an amateur so don't expect much, it may have problems. If it did, tell me.
end

remoteevent.OnClientEvent:Connect(onMouseClicked) --Connect the function to the event.

Step 3: Fire a Mouse.Button1Down event from the client in order to fire the afore-mentioned RemoteEvent.

That's all of it. These may have problems, so you may want to check before doing the exact same thing.

To conclude, these are also references for you to develop a more unique system, not something that could be taken for free without learning anything. I... also wasted my time writing this, but hope you're happy, and learnt something.

Cheers!

0
thanks so much!! MinuhaYT 19 — 5y
0
no probs! However, I suggest you reading this so as to avoid posting such questions: https://scriptinghelpers.org/help/how-post-good-questions-answers Afterl1ght 321 — 5y
Ad

Answer this question