So.
To begin, I want to say, that I have a Localscript and a saving leaderstats Script. I can't modify leaderstats with localscript, because they aren't saving. In order to save, I need to modify them with a server script. But! There is a huge problem.
I can't modify player leaderstats through Script (if you know a way, leave an answer asap!)
and
I can modify leaderstats through LocalScript, but they won't save, because the "Changed" event for leaderstats isn't registering when LocalScript is modifying values.
`` I tried to explain as best, as I could, please respond if you know!
Although sending your script would be nice, I'll do my best.
GLOBAL (Server/Normal Script):
1 | local statsChanged = game.ReplicatedStorage.statsChanged -- This assumes you have a "RemoteEvent" called "statsChanged" in ReplicatedStorage |
2 | statsChanged.OnServerEvent:connect( function (plr,points) |
3 | local leaderstats = plr.leaderstats |
4 | local savepoints = leaderstats:FindFirstChild( "points" ) |
5 | savepoints.Value = points |
6 | end ) |
LOCALSCRIPT:
1 | local points = pointstoaddidk |
2 | local statsChanged = fgame.ReplicatedStorage.statsChanged |
3 | -- I'll assume "points" will be a "NumberValue" |
4 | points.Changed:connect( function () |
5 | statsChanged:FireServer(points) |
6 | end ) |
This situation doesn't look to unstable, so if you could send a script to base my scripts off of, that'd be grand.
Or actually do something similar to what LawlR said in your comments: GLOBAL (Server/Normal Script):
1 | local players = game.Players |
2 | for i,plr in pairs (players:GetChildren()) |
3 | plr.leaderstats.Money.Value = plr.leaderstats.Money.Value + 5 |
4 | end |
The simple script above will add "5" to all players' money.