What do you want to achieve?
I want to make a leaderstat that saves.
What is the issue?
It dosent save
This is the code i used
local dataStoreService = game:GetService("DataStoreService")
local ds = dataStoreService:GetDataStore("DataStoreTest")
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr
local oofs = Instance.new("IntValue")
oofs.Name = "OOFS"
oofs.Parent = leaderstats
local rebriths = Instance.new("IntValue")
rebriths.Name = "Rebirths"
rebriths.Parent = leaderstats
local oofsData, rebrithsData
local success, errormessage = pcall(function()
oofsData = ds:GetAsync("oofs-"..plr.UserId)
rebrithsData = ds:GetAsync("rebirths-"..plr.UserId)
end)
if success then
oofs.Value = oofsData
rebriths.Value = rebrithsData
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
local success, errormessage = pcall(function()
ds:SetAsync("oofs-"..plr.UserId, plr.leaderstats.OOFS.Value)
ds:SetAsync("rebirths-"..plr.UserId, plr.leaderstats.Rebirths.Value)
end)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
i’ve copied your code but the code dosen’t work because of somme errors.
I’ve maneged to fix somme of them but i cant fix them all because i dont know how
Make sure API access and put some prints in the code, specifically after the pcall where you try to get the value of the data stores. Trying printing the error message, and the success message. Coders tip: Eliminate variables they may cause problems. Go down through your code and make sure each part works correctly.