local DataStore = game:GetService("DataStoreService") local PointsData = DataStore:GetOrderedDataStore("Points") game.Players.PlayerAdded:Connect(function(player) local points = PointsData:GetAsync(player.UserId) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" local pointsValue = Instance.new("IntValue",leaderstats) pointsValue.Value = points leaderstats.Parent = player pointsValue.Name = "Strength" end) game.Players.PlayerRemoving:Connect(function(player) local strength = player.leaderstats.Strength.Value PointsData:SetAsync(player.UserId.strength) print("Saved Data!") end)
Please help?
user id is a number (the number's user id, mine's 20111088 for example) you are trying to get the player.UserId.strength which literally means '20111088'.Strength.
a number does not have a strength value which is why your script is erroring.
i think you meant to say SetAsync(player.UserId, strength)
instead ofSetAsync(player.UserId.strength)
local DataStore = game:GetService("DataStoreService") local PointsData = DataStore:GetOrderedDataStore("Points") game.Players.PlayerAdded:Connect(function(player) local points = PointsData:GetAsync(player.UserId) local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" local pointsValue = Instance.new("IntValue",leaderstats) pointsValue.Value = points leaderstats.Parent = player pointsValue.Name = "Strength" end) game.Players.PlayerRemoving:Connect(function(player) local strength = player.leaderstats.Strength.Value --THIS IS WHAT YOUR CODE SHOULD LOOK LIKE vvvvv PointsData:SetAsync(player.UserId, strength) print("Saved Data!") end)