The reason it gives you that error is because you are saving strings instead of a table of strings, which would be fine except that you need 3 values saved and you are assigning the values as if it is a table.
i played my game with an alt and it didnt save. And where should i replace :GetAsync() with :SetAsync()?
Replace the :GetAsync() inside of the while loop with :SetAsync()
local Cashsuccess = pcall(function()
CashDS:SetAsync(player.UserId, {Cash2.Value, Cash.Value, Cash3.Value})
end)
Is that correct?
It should be, try it and see. Is that inside the while loop?
This is the while loop:
while wait(Autosave) do
print(""..player.Name.."'s Data is Saving...")
local Cashsuccess = pcall(function()
CashDS:SetAsync(player.UserId, {Cash2.Value, Cash.Value, Cash3.Value})
end)
if Cashsuccess then
print("Success")
end
end
It works in Studio but i tested it with an alt and it didnt work/save
Any errors? ------------------------------------------------
nope nothing not even the “success” message
That means it’s not saving your data for some reason. Did you wait long enough? Put a print statement inside the while loop but outside the if statement and see if it prints.
i waited long enough and i put a print statement a the beginning of the script witch does not show up too.
Can you post your code again? --------------
print("Check1")
local DataStore = game:GetService("DataStoreService")
local CashDS = DataStore:GetDataStore("CashDataStorage")
local Autosave = 10
game.Players.PlayerAdded:Connect(function(player)
print("Check2")
local Cashsuccess, newcash = pcall(function()
return CashDS:GetAsync(player.userId,0)
end)
print(newcash)
local leaderstats = Instance.new("Folder",player)
leaderstats.Name = "SavesFolder"
leaderstats.Archivable = true
local Cash2 = Instance.new("StringValue",leaderstats)
Cash2.Name = "AccDisabled"
local Cash = Instance.new("StringValue",leaderstats)
Cash.Name = "Save1"
local Cash3 = Instance.new("StringValue",leaderstats)
Cash3.Name = "PlayerPasswort"
Cash2.Value = newcash[1];
Cash.Value = newcash[2];
Cash3.Value = newcash[3];
while wait(Autosave) do
print(""..player.Name.."'s Data is Saving...")
local Cashsuccess = pcall(function()
CashDS:SetAsync(player.UserId, {Cash2.Value, Cash.Value, Cash3.Value})
end)
if Cashsuccess then
print("Success")
end
end
end)
Did it print the “Data is saving” message?
nope nothing is printing from this script, but other scrips can print.
Why did you print a 0 in the :GetAsync()? Also, where is the script placed and what type of script is it?
idk why its there but i removed it, The script is a “Script” and is in ServerScriptService
It should be printing at least something. You’ve either disabled the script or are not looking in the right place for the output.
Are you using the console to peek in at the output? If so, go to the server output and not the client.
The script is Enabled and its not printing even in the server output