ds = game:GetService("DataStoreService")
plr = script.Parent.Parent
wait(5)
game.Players:WaitForChild(script.Parent.Parent.Name):connect(function(plrAdded)
stats = Instance.new("IntValue", script.Parent.Parent)
stats.Name = "leaderstats"
kills = Instance.new("NumberValue", script.Parent.Parent:FindFirstChild("leaderstats"))
kills.Name = "Kills"
kills.Value = ds:GetASync("kills_"..script.Parent.Parent.userId)
cash = Instance.new("NumberValue", script.Parent.Parent:FindFirstChild("leaderstats"))
cash.Name = "Cash"
cash.Value = ds:GetASync("cash_"..script.Parent.Parent.userId)
end)
wait()
cash = plr:FindFirstChild("leaderstats").Cash.Value
kills = plr:FindFirstChild("leaderstats").Kills.Value
ds:SetASync("cash_"..plr.userId, cash)
ds:SetASync("kills_"..plr.userId, kills)
Error line 6. And many other errors. Please do not just fix this script. Please explain in depth what you did because I want to learn from my mistakes not just give it to someone else to fix and not learn from it.

1 comment
I used same variables twice.