-- This is a 5-way script. Thanks for using it!
function onPlayerEntered(player)
wait()-- Change to wait for player longer.
player:WaitForDataReady()
repeat wait() until player:FindFirstChild("leaderstats")
if player.DataReady then
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren()
for i = 1,#score do
local ScoreLoaded = player:LoadNumber(score[i].Name)
wait()
if ScoreLoaded ~= 0 then
score[i].Value = ScoreLoaded
end
end
end
end
end
function onPlayerLeaving(player)
if player:findFirstChild("leaderstats") then
local score = player.leaderstats:GetChildren()
for i = 1,#score do
player:SaveNumber(score[i].Name,score[i].Value)
end
end
end
game.Players.PlayerAdded:connect(onPlayerEntered)
game.Players.PlayerRemoving:connect(onPlayerLeaving)
that’s the datastore, my games stats are called “Time”
and “Rebirths”
when u rejoin you dont keep your time
the stats script is this
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “leaderstats”
leaderstats.Parent = player
I’m not sure why your using this at all, because it looks old and it isn’t even using functions that aren’t deprecated, deprecated functions and instances usually have issues or have been preceded by another instance/function.
There’s a really simple data store tutorial on the new and old Roblox API Website, I’m not sure why you just won’t use that instead, as its more updated then outdated.
I cant really write any code exampels atm. Ill just leave this short message instead. This script uses the outdated system" Data Persistence". It was disabled last year. Switch to Data Stores instead.