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?
As the error said you're trying to index a number.
PlayerData=DataStore:GetAsync(tostring(Player.UserId)
returns a number, not a NumberValue object. You can't call Clone on a number.
Perhaps you meant to do Player.plrData.Credits.Value = PlayerData