local DataStoreService=game:GetService("DataStoreService")
local DataStore=DataStoreService:GetDataStore("Player_Data")
game.Players.PlayerAdded:connect(function(Player)
local gameData;
local Stats=Instance.new('Folder')
Stats.Name="plrData"
local Money=Instance.new('NumberValue',Stats)
Money.Name="Credits"
Stats.Parent=Player
local SpecialMoney=Instance.new('NumberValue',Stats)
SpecialMoney.Name = "Resort Tokens"
local ownedWeapons=Instance.new('Folder',Stats)
ownedWeapons.Name = "ownedWeapons"
local CanSave=Instance.new('BoolValue',Player)
CanSave.Name="CanSaveData"
CanSave.Value=true
local DataFetchSuccess,ErrorMessage=pcall(function()
PlayerData=DataStore:GetAsync(tostring(Player.UserId))
end)
if DataFetchSuccess then
if PlayerData~=nil then
PlayerData:Clone().Parent = Player
else
Player.plrData.Credits.Value=100
end
else
Player.CanSaveData.Value=false
Player:Kick("[SERVER] DS002 (Check the Manual for more information.)")
end
end)
game.Players.PlayerRemoving:connect(function(Player)
if Player.CanSaveData.Value==false then return end
local PlayerData=Player.plrData
local DataWriteSuccess,ErrorMessage=pcall(function()
DataStore:SetAsync(tostring(Player.UserId),PlayerData)
end)
if not DataWriteSuccess then
local Retry_Count=0
while Retry_Count<6 do
wait(60)
local Succeded,Error=pcall(function()
DataStore:SetAsync(tostring(Player.UserId),PlayerData)
end)
if Succeded then break end
Retry_Count=Retry_Count+1
end
end
end)
On Line 31, it gives me the title error. How could I clone the player's data if they played already?

6 comments
How do I clone the folder from the DataStore to the player?
The DataStore didn't contain a folder, if you have a folder then you can use Clone. But in this case you had a number. You can't save objects like folders in DataStore.
Well how could I save plrData?
Save it as something else and not a folder, a table perhaps or a key for each value.
I want to use a table. How do I use tables with DataStores? (sorry for excessive asking xd)
You just use them... Try having a look at the wiki for datastore and table if you're unfamiliar with them.