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

How to fix bug with leaderstats data saving?

Asked by
kapipi12 133
6 years ago

I need to save leaderstats in DataStore. My leaderstats are:

Cash

InBucket

Catches

I need a universal but simple script for saving these, and also other values I didn't mention. I know there ARE TONS of tutorials and guides for it but seems like none helped me yet (out of date or too complex). Also, I already have these values created in a script, and I want to save in another, so please do not make them again. (IK it isn't a request site, if you are against requesters, try to at least explain.) Please help... Any help is much appreciated. Also, I deleted the script cause it didn't work, if you could explain me how to create new simple one, i would really appreciate it :)

1 answer

Log in to vote
2
Answered by
Kikitob 105
6 years ago

Ok I wrote this script for you that should save the stats. If you have any errors dm me and I will try to fix them. You could also look at the wiki for later stuff, for example DataStore in this case https://developer.roblox.com/api-reference/function/DataStoreService/GetDataStore .

01local DataStore = game:GetService("DataStoreService")
02local Http = game:GetService("HttpService")
03local Stats = DataStore:GetDataStore("Stats")
04 
05function GetStats(Player)
06    local Success,Return = pcall(function()
07        return Stats:GetAsync(Player.UserId)
08    end)
09    if Success then
10        Return = Http:JSONDecode(Return)
11        return Return
12    else
13        print("Getting data error :"..Return)
14        return {}
15    end
View all 41 lines...
Ad

Answer this question