Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My save data script doesn't work. I tried everything. How to fix it? (ROBLOX STUDIO)

Hi, In first sorry for my english, but I'm from Poland

I don't know what doesn't work. I made Data Saving script:

local DataStores = game:GetService("DataStoreService"):GetDataStore("MoneyDataStore")
local playersLeft = 0
local DSService = game:GetService('DataStoreService'):GetDataStore('Hamburger223232')

game.Players.PlayerAdded:Connect(function(player)
	
	   playersLeft = playersLeft + 1
 
 local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
 leaderstats.Parent = player
 
 local money = Instance.new("IntValue")
 money.Name = "StageSkips"
 money.Parent = leaderstats
local uniquekey = 'id-'..player.userId
local savevalue = Instance.new('IntValue')
savevalue.Parent = leaderstats
savevalue.Name = 'Stage'

-- GetAsync
local GetSaved = DSService:GetAsync(uniquekey)
if GetSaved then
 savevalue.Value = GetSaved[1]
else
local NumbersForSaving = {savevalue.Value}
DSService:SetAsync(uniquekey,NumbersForSaving) 
end

	  -- Data Stores

    local player_data

    pcall(function()
     player_data = DataStores:GetAsync(player.Userid.."-money") --1736284-Money
    end)

    if player_data ~= nil then
     -- Player has saved data , load it in
     money.Value = player_data
    else
     -- New player 
	print("It isn't player data oof")
     money.Value = 0
    end
 
end)

game.Players.PlayerRemoving:Connect(function(player)
 	local uniquekey = 'id-'..player.userId 
	local Savetable = {player.leaderstats.Stage.Value}
	DSService:SetAsync(uniquekey,Savetable)
     DataStores:SetAsync(player.UserId.."-money",player.leaderstats.StageSkips.Value)
 
end)

And "Stage" work, it's saving, loading etc., but StageSkips doesn't work, when i run the script Stage work, but StageSkips doesn't work, and in output appears "It isn't player data oof"

Thanks in advance

3 comments

0

PS the first code as a second also does not work

0

try it outside of studio

0

it's don't work anyway

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.