01 | local DataStoreService = game:GetService( "DataStoreService" ) |
02 | local DataStore = DataStoreService:GetDataStore( "Player_Data" ) |
03 | game.Players.PlayerAdded:connect( function (Player) |
04 |
05 | local gameData; |
06 | local Stats = Instance.new( 'Folder' ) |
07 | Stats.Name = "plrData" |
08 | local Money = Instance.new( 'NumberValue' ,Stats) |
09 | Money.Name = "Credits" |
10 | Stats.Parent = Player |
11 | local SpecialMoney = Instance.new( 'NumberValue' ,Stats) |
12 | SpecialMoney.Name = "Resort Tokens" |
13 | local ownedWeapons = Instance.new( 'Folder' ,Stats) |
14 | ownedWeapons.Name = "ownedWeapons" |
15 |
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