Hello
I have the api enabled and the place is on roblox....just to get this out of the way.
I'm pretty new to roblox lua and been searching online for some help with a data-stores. I watched some youtube videos, but they have scripted differently. They added there leaderstats and Int-value within the data script.
my issues is;
I have my leaderstats and values inside my server script service and cloned it and used a player added function which when a player joins the clone is put under the players name.
Basically, i have to figure out how to data-store a clone leaderstats intvalue.
Is this even possible to datastore a clone? anyways here was me trying to get this to work
Here is what my server script services looks like (links below), and my leader board clone script.
https://i.gyazo.com/7a165e7345dffa90379fe08a77dc5890.png
https://i.gyazo.com/efd37efc47c21e52627d149de445da6b.png
So, i made another non-local script in server script service and named it Datastore and then below is me testing the intvalue cookies to see if it will save when closed. I ran the game again and the value went back to 0 hehe fail...not sure what too do here....
any suggestions would be appreciated
"To simplify what i'm needing to do is save the cloned cookie intvalue" as you can tell im not sure how to XD
local datastore = game:GetService("DataStoreService") local ds1 = datastore:GetDataStore("CookiesSaveSystem") local ds2 = datastore:GetDataStore("RebirthSaveSystem") local cookies = game.ServerScriptService.leaderboard.leaderstats.Cookies local rebirths = game.ServerScriptService.leaderboard.leaderstats.Rebirths local folder = game.ServerScriptService.leaderboard.leaderstats game.Players.PlayerAdded:Connect(function(player) cookies.Value = ds1:GetAsync(player.UserId) or 0 ds1:SetAsync(player.UserId, cookies.Value) cookies.Changed:Connect(function() ds1:SetAsync(player.UserId, cookies.Value) end) end)
I probably should've led you to the answer not given it but this should help.
local datastore = game:GetService("DataStoreService") local ds1 = datastore:GetDataStore("CookiesSaveSystem") function savetablefunc(player)--a table is much more efficient for saving local savetable = { cookies = player.leaderstats.Cookies.Value, rebirths = player.leaderstats.Rebirths.Value } return savetable end game.Players.PlayerAdded:Connect(function(player) local clone = script.leaderstats:Clone()--here we clone the files over clone.Parent = player local save = savetablefunc(player) local savedstuff = ds1:GetAsync(player.userId) function datapull(player,save) -- here we pull the saved data into the ints we cloned player.leaderstats.Cookies.Value = savedstuff.cookies player.leaderstats.Rebirths.Value = savedstuff.rebirth end datapull(player,save) end) function savedata(player) --this is just the function to call on leaving local save = savetablefunc(player) ds1:SetAsync(player.userId,save) end game.Players.PlayerRemoving:Connect(savedata)-- here we save the data on player leaving, you dont need on change its wasteful in most cases