So I’ve been using a script to save the leaderboard in my RPG game and it has been working fine until the latest update now whenever I join all my cash is set to 0. The script is a server script in the workspace.
print("Points AutoSave Script Loaded Successfully!! :D")
game.Players.PlayerRemoving:connect(function(p)
if p:findFirstChild("leaderstats") then
p:SaveInstance("SavedStatPNum"..tostring(game.PlaceId),p.leaderstats)
end
end)
game.Players.PlayerAdded:connect(function(p)
for k = 1, 60, 0.03 do
wait()
if p:findFirstChild("leaderstats") and p.DataReady then break end
end
local Loaded = nil
if p:findFirstChild("leaderstats") and pcall(function() Loaded = p:LoadInstance("SavedStatPNum"..tostring(game.PlaceId)) end) then
for j, v in pairs(Loaded:GetChildren()) do
pcall(function() p.leaderstats[v.Name].Value = v.Value end)
end
end
end)
then the leaderboard
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Cash = Instance.new("NumberValue")
Cash.Name = "Cash"
Cash.Value = 0
Cash.Parent = leaderstats
end)
Any ideas to fix this?