Leaderstat Question

Hello, so if I already have a module script for my leaderstats and want to make a server script for my gamepass handler, how could I make it so I call the leaderstats from the server script?

Is the leaderstats stored in a leaderstats folder under the player? If so, you can just use

player.leaderstats.(value name)

to access a value.

It is, however when I do your solution it just gives me an error saying leaderstats is not a valid member of Player "Players.5Flipz"

Assuming you don’t buy anything in the game, but rather own the gamepass and it is running as soon as the game starts, try doing

player:WaitForChild("leaderstats")

instead of trying to call on it immediately as it might be created after that piece of code runs.

I typed the following code

player:WaitForChild("leaderstats").Cash.Value = player:WaitForChild("leaderstats").Cash.Value * 2

and it gave me this error ServerScriptService.GamepassShopServer:8: attempt to perform arithmetic (mul) on string and number

It appears your cash is a string. Change it into a NumberValue and not a StringValue. Also, you can shorten it like this :slight_smile:

player:WaitForChild("leaderstats").Cash.Value *= 2
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.