so my save data leaderstats script works. but not for one of my friends (hes the owner) any help?
local dss = game:GetService("DataStoreService")
local ss = dss:GetDataStore("PlayerStageDataStore")
function plrToStage(plr)
repeat wait() until plr.Character.HumanoidRootPart
local sp = game.Workspace.Checkpoints:FindFirstChild(tostring(plr.leaderstats.Stage.Value))
plr.Character.HumanoidRootPart.CFrame = sp.CFrame + Vector3.new(0,2.5,0)
end
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local stage = Instance.new("IntValue")
stage.Name = "Stage"
stage.Parent = leaderstats
local success, errorMsg = pcall(function()
stage.Value = ss:GetAsync(player.UserId)
end)
if success then
print("Got "..player.Name.."'s Data.")
else
warn(errorMsg)
end
player.CharacterAdded:Connect(function()
plrToStage(player)
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errorMsg = pcall(function()
ss:SetAsync(player.UserId,player.leaderstats.Stage.Value)
end)
if success then
print("Saved "..player.Name.."'s Data.")
end
end)
for _, checkpoint in pairs(game.Workspace.Checkpoints:GetChildren()) do
checkpoint.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local cn = tonumber(checkpoint.Name)
if player.leaderstats.Stage.Value < cn then
player.leaderstats.Stage.Value = cn
end
end
end)
end