local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(player)
local char = player.Character or player.CharacterAdded:wait()
local ack = Instance.new("IntValue")
ack.Name = "leaderstats"
local ack2 = Instance.new("IntValue")
ack2.Name = "Stage"
ack2.Value = 1
ack2.Parent = ack
ack.Parent = player
local ack3 = Instance.new("IntValue", ack)
ack3.Name = "Prestige"
ack3.Value = 0
local Folder = Instance.new("Folder", player)
local ack4 = Instance.new("IntValue", player)
ack4.Name = "Skips"
ack4.Value = 0
player:LoadCharacter()
local ls = player.leaderstats
local sl = game.Workspace:FindFirstChild(ls.Stage.Value)
print(sl.Position)
char.UpperTorso.CFrame = sl.CFrame + Vector3.new(0,3,0)
local char = player.Character or player.CharacterAdded:wait()
print(sl.CFrame)
local data
local data2
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(player.UserId .. "-Stage")
data2 = myDataStore:GetAsync(player.UserId .. "-Prestige")
end)
if success then
ack2.Value = data
local sl = game.Workspace:FindFirstChild(ls.Stage.Value)
local char = player.Character or player.CharacterAdded:wait()
if char:WaitForChild("UpperTorso") then
char:WaitForChild("UpperTorso").CFrame = sl.CFrame + Vector3.new(0,3,0)
end
print(sl)
ack3.Value = data2
else
ack2.Value = 1
warn(errormessage)
end
workspace.ChildAdded:Connect(function(obj)
if obj.Name == player.Name then
if obj:WaitForChild("UpperTorso") or obj:WaitForChild("Torso") then
local sl = game.Workspace:FindFirstChild(ls.Stage.Value)
obj:WaitForChild("UpperTorso").CFrame = obj:WaitForChild("UpperTorso").CFrame + Vector3.new(0,3,0)
print(sl.CFrame)
end
wait()
if obj:WaitForChild("UpperTorso") or obj:WaitForChild("Torso") then
local sl = game.Workspace:FindFirstChild(ls.Stage.Value)
obj:WaitForChild("UpperTorso").CFrame = sl.CFrame + Vector3.new(0,3,0)
end
end
end)
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
myDataStore:SetAsync(player.UserId .. "-Stage", player.leaderstats.Stage.Value)
myDataStore:SetAsync(player.UserId .. "-Prestige", player.leaderstats.Prestige.Value)
end)
if success then
print("Data Saved!")
else
warn(errormessage)
end
end)
If a player has data they will spawn in the right place after dying once. If a player does not have data they will be on stage 0 and fall to their death infinitely.
On line 40: Attempt to index nil with 'CFrame'

2 comments
Not all characters have uppertorso. Use HumanoidRootPart instead.
Didn't work and it had the same error