local dataStore = game:GetService("DataStoreService"):GetDataStore("myStore") function userEntered(newPlayer) local clientFolder = Instance.new("Folder") clientFolder.Parent = newPlayer clientFolder.Name = "Client Data" local knockouts = Instance.new("IntValue") knockouts.Parent = clientFolder knockouts.Name = "Knockouts" knockouts.Value = 0 local gamesPlayed = Instance.new("IntValue") gamesPlayed.Parent = clientFolder gamesPlayed.Name = "Games Played" local userKey = "usr-"..newPlayer.UserId local dataTable = dataStore:GetAsync(userKey) if dataTable then knockouts.Value = dataTable[1] gamesPlayed.Value = dataTable[2] else print(1) local dataTable = {knockouts.Value, gamesPlayed.Value} dataStore:SetAsync(userKey, dataTable) end end function userLeaving(oldPlayer) local userKey = "usr-"..oldPlayer.UserId local clientFolder = oldPlayer:FindFirstChild("Client Data") local dataTable = {clientFolder.Knockouts.Value, clientFolder["Games Played"].Value} dataStore:SetAsync(userKey, dataTable) end game.Players.PlayerAdded:Connect(userEntered) game.Players.PlayerRemoving:Connect(userLeaving)
When I run the game, the values show as "0" as if the Data Store did not load the values. Does anyone know why?
Thank you.