How would I make better clickers in a simulator?

  1. What do I want to achieve? I want to make it to where you can buy better clickers in a simulator game I am trying to make.

  2. What is the issue? I am not really sure how I would do this because I am new to developing and don’t understand how to do some things. This is the script that already has a rebirth multiplier for when I add that in. I want to add the better clickers to take affect here.

player.leaderstats.Points.Value = player.leaderstats.Points.Value + 1 * (player.leaderstats.Rebirths.Value + 1)

All of that script is on one line in roblox studio.

  1. What solutions have you tried so far? I have tried looking on YouTube and The devforum for solutions but I have not found any.

I’m sorry if this is a sloppy post. This is my first time posting on the dev forum. If this should be in a different category or I could make this more clear, please tell me.

4 Likes

My personal method would be to keep a StringValue in the player’s leaderstats which has the Value of their current clicker.
Then when they buy a clicker, this Value is changed.

When adding points, access a ModuleScript containing the clicker data and index the Player’s current clicker.
Now you can grab the amount it gives and other data etc.

Here’s an example:

--// Script, ServerScriptService

local ClickerData = require(script.ModuleScript);

--// When rewarding points
local Leaderstats = Player.leaderstats;
local PlayerData = ClickerData[Leaderstats.Clicker.Value];
Leaderstats.Points.Value = Leaderstats.Points.Value + (PlayerData.Amount * (Leaderstats.Rebirths.Value + 1));
--// ModuleScript, ServerScriptService.Script

return {
    ["Default"] = { Amount = 1 };
};
1 Like

Ok, I will try this. Would I need to insert the string value into the leaderstats when the player joins using and instance code?

Of course, y’know it’d be easier if you premade the leaderstats in studio and just cloned it.

It’ll make the job much simpler than long Instance.new blocks.

1 Like

Ok, I’m still learning how to script on roblox so could you please explain how I would do that if Possible.
Thanks for the help.

Create it in studio like you usually would, and then put it in a secure place, my rule of the thumb would be ServerStorage.

Then all you do is just call the Clone method, it’s that simple.

local leaderstats = game:GetService("ServerStorage").leaderstats:Clone()
--// Do stuff
leaderstats.Parent = Player

So, I would create an integer value in serverstorage and clone it to the player folder?

No no, the full leaderstats Folder that you use.
You’d clone it and put it in the Player.

Oh ok. I have been watching some videos talking about leaderstats and they have been making an instance.new code run for leaderstats and everything that goes in it.

Would It look something like this?

Put your “CloneScript” in ServerScriptService and you should be good. :slight_smile:

Actually just saw another correction, replace your current code with this:

local leaderstats = game.ServerStorage:WaitForChild("leaderstats")
game.Players.PlayerAdded:Connect(function(player) --//Player is automatically passed in when players join
leaderstats:Clone().Parent = player
end)
1 Like

Ok, thanks for the help. This is my first real game I’m trying to make and I just watched youtube videos to figure out how to implement codes. Now that you have showed me this easier way to do this, I think I will start over because I haven’t made much progress with the game and my scripts are a mess with hard ways to do things. Thanks for the help! I just need to reorganize things so I can Implement new things into my code easier

1 Like

I actually just made that and what I did is added the value to the PlayerGui. So each upgrade by clicking a button fires a client event which makes the server go to the PlayerGui of that particular player and multiplies/adds value.