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

How to find our leaderstats of Cash?

Asked by 7 years ago

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

0
cash is not a standard item in games - are you sure your game has this setup? JasonTheOwner 391 — 7y
0
Can you include the script. User#5423 17 — 7y
0
how do i include the script? Zidraf123 0 — 7y
0
I dont know Slushiiee 0 — 7y

1 answer

Log in to vote
1
Answered by
ARTEK22 135
7 years ago

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!

Ad

Answer this question