Player is not a valid member of datamodel 1. I check the code a-lot of times and can't see the problem. Please tell me what I need to change. Btw I was making a save system. Please check this code and see what the problem.
Script:
local dataStores = game:GetService("DataStoreService"):GetDataStore("ItenseDataStore") local defaultPoints = 10 local playerLeft = 0 player = game.Players.LocalPlayer
game.Players.PlayerAdded:Connect(function(player)
playerLeft = playerLeft + 1 local leaderstats = Instance.new("Folder") leaderstats.Name = "leaderstats" leaderstats.Parent = player local points = Instance.new("IntValue") points.Name = "Points" points.Value = 0 points.Parent = leaderstats local val = Instance.new("IntValue") val.Name = "Wins" val.Value = 0 val.Parent = leaderstats local player_data pcall(function() player_data = dataStores:GetAsync(player.UserId.."-Points") end)
if player_data ~= nil then points.Value = player_data else --New Player points.Value = defaultPoints
end
end)
local bindableEvent = Instance.new("BindableEvent")
game.Players.PlayerRemoving:Connect(function(player) pcall(function() dataStores:SetAsync(player.UserId.."-Points",player.leaderstats.points.Value) print("Saved") playerLeft = playerLeft - 1 bindableEvent:Fire() end)
end)
game:BindToClose(function()
while playerLeft > 0 do bindableEvent.Event:Wait() end
end)