Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to find our leaderstats of Cash?

I don't know how to find our leaderstats of cash, I've tried game.Players.LocalPlayer.leaderstats. and then the output say the variable has a nil value, Please help me by answer this

4 comments

0

cash is not a standard item in games - are you sure your game has this setup?

0

Can you include the script.

0

how do i include the script?

0

I dont know

1 answer

So, I suppose you were trying to make a leaderstats script. It worked, but you couldn't get the amount of your cash.

I suppose your script might be using a similar source to this code: (source: wiki)

game.Players.PlayerAdded:connect(function(player)
     local leaderstats = Instance.new("Model")
     leaderstats.Name = "leaderstats"
     leaderstats.Parent = player
 
     local money = Instance.new("IntValue") --We create a new IntValue
     money.Name = "Money" --this is the name you want the leader-stat to be when it shows up in-game.
     money.Value = 0 --this is the value of money the new player starts out with. To change this, you can add some more code (shown later)
     money.Parent = leaderstats -- Set the money object as a child of the leaderstats object.
 end)

As you can see that the script creates a new folder called "leaderstats" in the player. It is located here: game.Players.LocalPlayer.leaderstats

The problem is: It's just a folder. It dosen't store the "Cash" by itself, but as you can see the script makes a value called "Money" or "Cash" for you.

Values are some sort of variables that store data. So, let's try to access the Value of "Cash".

game.Players.LocalPlayer.leaderstats.Cash.Value

Alright! We've got ourselfes the number of the cash of the local player! Now you can use it for some kind of stores, cash earning and others! Enjoy!

This discussion is preserved as it was. New answers, comments, and votes are closed.