ClickDetector Cash Script not working

I replaced stats with leaderstats. There is still an error.

I said specifically ‘leaderstats’, with lower-case L and S. Though, changing the values locally won’t work anyways as this must be done by the server.

I changed both letters to lowercase. Still an error.

Could you provide a screenshot of the explorer? Considering you tried to index player.Stats, I assume you have something corresponding to it parented to the player object?

There’s explorer. The script at the bottom is for welcoming the player.

You have to insert leaderstats into the player.

I don’t comprehend how you’re trying to index something which is never created locally nor server-side?

Though, you might have a look at the post I recently made for someone else regarding something quite similar for creating leaderstats:

[color=#FFC900] Considering you mentioned that you’re new to scripting then I recommend that you pay specific attention to how the explorer in the post is set up and which script type (script or localscript) is being used for the code provided in the post I referred to.[/color]

I’m new to scripting. How exactly do I do that?

You have to put the name of the folder inside the player or else it won’t work

Oh, and here’s a screen shot of the tutorial:


This is what I used to create the script.

Insert a script into ServerScriptService and create a new folder named leaderstats whenever a player joins.
For example:

game.Players.PlayerAdded:Connect(function(player) --getting the player who joined
    local leaderstats = Instance.new("Folder", player) --making a new folder and inserting it into the player
    leaderstats.Name = "leaderstats"

    local cash = Instance.new("IntValue",leaderstats) --creating the cash value and inserting it into the folder
    cash.Name = "Cash"
    cash.Value = 500 --starting cash amount
end)

A comment on your code: stay away from the parent argument of Instance.new.

The post I referred to already provides a code example for this + the way you’re creating the Instances isn’t performant and is rather poor practice.

Will do, thanks for the tip :grin:

That actually worked. Thank you @Enclamatic and @rawbyte.

  1. Remember to set and change the values on the server and not locally with a LocalScript - make sure to have a look at Remote Functions and Events for this.
  2. I actually provided the correct code with no deprecated nor non-performant methods so my post is quite the more correct solution.

I just tried your method and the code didn’t work. @Enclamatic does work so i’m gonna use his method. But thank you for helping me though :+1: :happy2:.

Then you implemented it incorrectly and didn’t set up the leaderstats folder on before-hand.

image

As I mentioned, pay attention to how I set it up.

Alright, so I did fix the issue. And your method is so much better. Thanks @rawbyte. No offense to @Enclamatic.

next time use a lua block instead of screenshots.