Answered by
6 years ago Edited 6 years ago
I'll assume you have the leaderstats already set up, but if you don't, I have attached a link at the bottom of this answer that will help you do that.
1 | Player = game.Players:GetPlayers() |
3 | Player.leaderstats [ Currency ] .Value = Player.leaderstats [ Currency ] .Value + 30 |
The problem here is that the variable "Player" is referring to a table of players, which is what :GetPlayers() returns. It then tries to search that table for a value "leaderstats," but does not find it. In order to change each player's stats, you'll have to loop through the table of players. Here is a solution that will add to each player's stat.
1 | local Players = game.Players:GetPlayers() |
4 | Players [ i ] .leaderstats [ Currency ] .Value = Player [ i ] .leaderstats [ Currency ] .Value + 30 |
If you want to give stats to a specific player:
1 | local Player = game.Players.PlayerNameHere |
3 | Player.leaderstats [ Currency ] .Value = Player.leaderstats [ Currency ] .Value + 30 |
Here are some resources on loops and creating leaderstats:
https://developer.roblox.com/articles/Roblox-Coding-Basics-Loops
https://developer.roblox.com/articles/Leaderboards