local ScoreKey = PlayerScore
game.Players.PlayerAdded:connect(function(player)
local stats = Instance.new("Model", player)
stats.Name = "leaderstats"
local points = Instance.new("IntValue", stats)
points.Name = "Points"
points.Value = 0
local tpoints = Instance.new("IntValue", stats)
tpoints.Name = "Total points"
tpoints.Value = 0
local Deaths = Instance.new("IntValue", stats)
Deaths.Name = "Deaths"
Deaths.Value = 0
end)
script.Parent.Humanoid.Died:connect(function()
local user = script.Parent.Humanoid.creator.Value
user.leaderstats.Points.Value = user.leaderstats.Points.Value + 100
user.leaderstats["Total Points"].Value = user.leaderstats["Total Points"].Value + 100
end)
script.Parent.Parent.Humanoid.Died:connect(function()
script.Parent.Parent.leaderstats.Deaths.Value = script.Parent.Parent.leaderstats.Deaths.Value + 1
end)
game.Players.PlayerRemoving:connect(function(player)
game.Players.PlayerAdded:connect(function(player)
if player:WaitForDataReady() then
player:SaveNumber(ScoreKey, player.leaderstats.Points)
player:SaveNumber(ScoreKey, player.leaderstats.Deaths)
player:SaveNumber(ScoreKey, player.leaderstats["Total Points"])
end
end)
end)
game.Players.PlayerRemoving:connect(function(player)
game.Players.PlayerAdded:connect(function(player)
if player:WaitForDataReady() then
player:LoadNumber(ScoreKey, player.leaderstats.Points)
player:LoadNumber(ScoreKey, player.leaderstats.Deaths)
player:LoadNumber(ScoreKey, player.leaderstats["Total Points"])
end
end)
it worked fine until the adding to values part |