Job Leveling System

Helle everybody,

I’m a scripter and working on a new game, i want to make a job leveling system that saves i will explain what i mean by this.

For example if you click a part you get 10 cash and if you click 20 times on the part you level up, if you level up you get 15 cash instead of 10 cash per click.

The problem is that I don’t have any idea how to start a job leveling system that saves.

Thanks,

4 Likes

You could save their level & cash via a DataStore (basic steps).

Then, you can have an array for what that level earns.
For example:

local levelRewards = {
	One = 10
}

You could then store the amount of times a player clicks on a part and then reset it when they level up.

Part.ClickDetector.MouseClick:Connect(function(Player)
     --// do something
     ...
end)
1 Like

I know how to creat the money giving part but i don’t know how to create the leveling part, but thanks for replying!

1 Like

Well, have your IntValue in the player’s descendants and add onto it when needed. Save it the same way you save your cash.

image

You’ll also need to store the amount of times the player has clicked a part.

if tonumber(PartClicks.Value) > 20 then 
 Level.Value = tonumber(Level.Value) + 1
 PartClicks.Value = 0
1 Like

Start by creating a table that keeps track of how many clicks have been done.

local Clicks = {}

Then, continue by making a function for each time a ClickDetector is clicked on.

local function onClicked(player)
     local value = Clicks[player.Name]
     Clicks[player.Name] = value + 1
end

ClickDetector.MouseClick:Connect(onClicked)

Then check for the Clicks count and if it reaches a certain value or more, they level up.

local levelTracker = {}

local function levelUp(plr)
    local CurrentLevel = levelTracker[plr.Name]
    levelTracker[plr.Name] = CurrentLevel + 1
    --run any other code
end

local function onClicked(player)
     local value = Clicks[player.Name]
     Clicks[player.Name] = value + 1
     if Clicks[player.Name] >= 20 then -- checks here
        Clicks[player.Name] = Clicks[player.Name] -  20
        levelUp(player, Clicks[player.Name])
     end
     --run any other code
end

Then run any code that should follow suit after.

Let me know if this helped, if it didn’t then I apologise for not being helpful to your issue.

1 Like

Thank but how do i do it if the player has reached that level the next level is like 20 clicks higher

1 Like

Thanks i will look into that, but i son’t think that is what i’m looking for, but thanks for the reply! :slight_smile:

1 Like

That’s not difficult at all, in fact I have already included it in my previous code.

local function onClicked(player)
     local value = Clicks[player.Name]
     Clicks[player.Name] = value + 1
     if Clicks[player.Name] >= 20 then -- checks here
        Clicks[player.Name] = Clicks[player.Name] -  20
        levelUp(player, Clicks[player.Name])
     end
     --run any other code
end
1 Like

That’s not what i meant, I meant like for each level your click for the next level is higher

1 Like

Please elaborate, I’m not sure what you mean.

Look

Level 1 requires 20 clicks for the next level
Level 2 requires 40 clicks for the next level
Level 3 requires 60 clicks for the next level

Do you mean, you want it to tell the player how many clicks are required to reach the next level and as they click, the count subtracts?

Yes exactly
For each level the clicks for the next level increases

Ah so, I think you mean having it tell the player how many clicks they need, alright so…

Start by creating a Humanoid and parenting it to the Model that holds the main part that is clicked on. Then, name the part that the player clicks on “Head”.

Rename the model to whatever you please,
(the player will first see this before they begin clicking away).

Create a table yet again (ClicksNeeded in my example) and make it so that when a player first joins they need 0 and are level 0. Then when the player first clicks, change them to level 1 immediately and using the Levels array, make it so that at some point, the clicks needed gets its amount by using Levels[level].

local Level = {}
local Levels = {20,40,60,80,100}
local Model = -- put model location here

local function onClicked(player)
     local value = Clicks[player.Name]
     Clicks[player.Name] = value + 1
     if Clicks[player.Name] >= 20 then -- checks here
        Clicks[player.Name] = Clicks[player.Name] -  20
        levelUp(player, Clicks[player.Name])
     end
     local value2 = ClicksNeeded[player.Name]
     ClicksNeeded[player.Name] = ClicksNeeded[player.Name] - 1
     Model.Name = “You need ”..ClicksNeeded[player.Name]..“ to reach ”..Level[player.Name] + 1
     --run any other code
end

It is vital to note that this means that the count shown will depend on the last person who interacted with it (of course it is interchangeable between players because of the way I coded it).

3 Likes

Thank you very much!!
Now i have something to begin with thanks!

1 Like