#Leaderstats not saving
1 messages · Page 1 of 1 (latest)
-- Make sure "Enable Studio Access To API Services" is on in Game Settings! (OR IT WON'T WORK) --
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local Saver = DataStoreService:GetDataStore("SaveLeaderstats")
Players.PlayerAdded:Connect(function(player)
local Data = nil
local success, errormessage = pcall(function()
Data = Saver:GetAsync(tostring(player.UserId))
end)
if success then
if Data then
for i, v in pairs(Data) do
player:WaitForChild("leaderstats"):WaitForChild(i).Value = v
end
end
else
error(errormessage)
end
end)
local function Save(player)
local SavedData = {}
for _, v in pairs(player.leaderstats:GetChildren()) do
SavedData[v.Name] = v.Value
end
local success, errormessage = pcall(function()
Saver:SetAsync(tostring(player.UserId), SavedData)
end)
if not success then
error(errormessage)
end
end
Players.PlayerRemoving:Connect(Save)
game:BindToClose(function()
for _, v in pairs(Players:GetPlayers()) do
Save(v)
end
end)
This is the script i use
its a free script i found on yt
How do you add ur currency
I just used ChatGPT to do it
-- Make sure "Enable Studio Access To API Services" is on in Game Settings! (OR IT WON'T WORK) --
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local Saver = DataStoreService:GetDataStore("SaveLeaderstats")
Players.PlayerAdded:Connect(function(player)
local Data = nil
local success, errormessage = pcall(function()
Data = Saver:GetAsync(tostring(player.UserId))
end)
if success then
if Data then
for i, v in pairs(Data) do
player:WaitForChild("leaderstats"):WaitForChild(i).Value = v
end
end
else
error(errormessage)
end
end)
local function Save(player)
local SavedData = {}
for , v in pairs(player.leaderstats:GetChildren()) do
SavedData[v.Name] = v.Value
end
local success, errormessage = pcall(function()
Saver:SetAsync(tostring(player.UserId), SavedData)
end)
if not success then
error(errormessage)
end
end
Players.PlayerRemoving:Connect(Save)
game:BindToClose(function()
for , v in pairs(Players:GetPlayers()) do
Save(v)
end
end)
And it worked
that looks similar
idk about chatgpt i didnt know it could do these scripts
ill try asking the assistant thing to make me datastore script
yeah the problem isnt in the script
Alright
i did and
i got a script
i set it up but it still doesnt work
What error told you?
i even tried multiple scripts
no error
it just doesnt save
and i do have api enabled
it should
woerk
try using profilestore instead
how
read the docs
huh
idk how to use profile stor
He need you to explain to him
✅
“ProfileStore” by loleris (Successor module to ProfileService) [GitHub repo] ProfileStore is a Roblox DataStore wrapper that streamlines auto-saving, session locking and a few other features for the game developer. ProfileStore’s source code runs on a single ModuleScript. Read documentation here: ProfileStore wiki (Click me) Get the m...
i dont know how to explain it i just watched a youtube video https://www.youtube.com/watch?v=m2SP_TLeWHI
You need to be using ProfileStore in all of your Roblox gamedev projects! In this tutorial, we learn why it's better than default Data Stores and how to set it up. No sweat!
Thanks for watching! I'm a Roblox game developer teaching Roblox players how to create their own games. Subscribe to learn more!
Download ProfileStore:
https://create.robl...
Hope this help
and it was clearly easier
There are different kind method of data saving
its the same just formatted correctly
oh
yeah consider it
send us the script where you create leaderstats etc.
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Rarity = Instance.new("IntValue")
Rarity.Name = "Rarity"
Rarity.Value = 0
Rarity.Parent = leaderstats
local Rolls = Instance.new("IntValue")
Rolls.Name = "Rolls"
Rolls.Value = 0
Rolls.Parent = leaderstats
end)
also this thing doesnt work
cuz of "for ,"
so does it work now with fixing ts
I wouldn't recommend profilestore for beginners tbf
https://www.youtube.com/watch?v=m2SP_TLeWHI watch this slowly
You need to be using ProfileStore in all of your Roblox gamedev projects! In this tutorial, we learn why it's better than default Data Stores and how to set it up. No sweat!
Thanks for watching! I'm a Roblox game developer teaching Roblox players how to create their own games. Subscribe to learn more!
Download ProfileStore:
https://create.robl...
i did everything right
it didnt work aswell for me
ok bro 27 mins are we deadass
** You are now Level 10! **
Rescript it well bit pain thought
itll help a lot
fr me too
uhh
i got the script but its different than the script in the video
and i did download it from it
wgat
uhh
then u can just use that class to save data / retrieve it
dude? feel like more lecture
dos it manage only leaderstats or what
oh
bro you so confident about that eh
hehe @limber sundial
give me access ur game probly speed up process
i got all free time @limber sundial
is not lie
let me work my magic
im pretty sure i must have you added to give u access
what ur user?
MOO_OOOI
fast friends request incoming
there you go
i gave you access
keep in mind i have the game saved so it doesnt matter if ur brewing something malicious
and dont ask what is this game about
i understand have work with my friend game
** You are now Level 13! **
?
ok
i did try in my place
and it worked?
yeah it doesnt in mine
i also have to go now, if u want you can try to finish the profilestore or edit whatever you created and make sure to tell me what have you done while i was gone
Why u dont reply?
i give up ur systems is not possible
Yeah im not surprised
I dont think i made it work
Can you help somehow?
bro data saving not hard
@limber sundial i gotchu
@limber sundial -- Make sure "Enable Studio Access To API Services" is on in Game Settings! (OR IT WON'T WORK) --
local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local Saver = DataStoreService:GetDataStore("SaveLeaderstats")
Players.PlayerAdded:Connect(function(player)
local Data = nil
local success, errormessage = pcall(function()
Data = Saver:GetAsync(tostring(player.UserId))
end)
if success then
if Data then
for i, v in pairs(Data) do
player:WaitForChild("leaderstats"):WaitForChild(i).Value = v
end
end
else
error(errormessage)
end
end)
local function Save(player)
local SavedData = {}
for _, v in pairs(player.leaderstats:GetChildren()) do
SavedData[v.Name] = v.Value
end
local success, errormessage = pcall(function()
Saver:SetAsync(tostring(player.UserId), SavedData)
end)
if not success then
error(errormessage)
end
end
Players.PlayerRemoving:Connect(Save)
game:BindToClose(function()
for _, v in pairs(Players:GetPlayers()) do
Save(v)
end
end)