Obby teleport script help(simple fix?)

Hi,

I’m making a simple obby script, which teleports you to the stage you are at, after you die. But the script doesn’t seem to work, would anyone know how to fix this issue?

local datastoreservice = game:GetService(“DataStoreService”)
local StageData = datastoreservice:GetDataStore(“StageData”)

game.Players.PlayerAdded:Connect(function(Player)

local leaderstats = Instance.new("Folder",Player)
leaderstats.Name = "leaderstats"

local Stage = Instance.new("IntValue",leaderstats)
Stage.Name = "Stage"
Stage.Value = StageData:GetAsync(Player.UserId) or 0

Stage.Changed:connect(function()
	StageData:SetAsync(Player.UserId,Stage.Value)

Player.CharacterAdded:Connect(function(Character)
repeat wait() until Player.Character ~= nil
local Stage = workspace.Stages:FindFirstChild(Stage.Value)
Character:WaitForChild(“HumanoidRootpart”).CFrame = CFrame.new(Stage.Position + Vector3.new(0,2,0))
end)

end)

end)

Maybe try changing the script to this:

local datastoreservice = game:GetService(“DataStoreService”)
local StageData = datastoreservice:GetDataStore(“StageData”)

game.Players.PlayerAdded:Connect(function(Player)

local leaderstats = Instance.new("Folder",Player)
leaderstats.Name = "leaderstats"

local Stage = Instance.new("IntValue",leaderstats)
Stage.Name = "Stage"
Stage.Value = StageData:GetAsync(Player.UserId) or 0

Stage.Changed:connect(function()
	StageData:SetAsync(Player.UserId,Stage.Value)
Player.CharacterAdded:Connect(function(Character)
repeat wait() until Player.Character ~= nil
local StageE = workspace.Stages:FindFirstChild(Stage.Value)
Character:WaitForChild(“HumanoidRootpart”).CFrame = CFrame.new(StageE.CFrame.X, StageE.CFrame.Y + 2, StageE.CFrame.Z) --The reason why I changed to CFrame because I usually use this.
end)

end)
end)

Also please do not send codes here, it is unrecommended to do so.

Thanks for the help, but it still doesn’t seem to work. I just spawn in a random location.
Also, where would i send codes?
image

You could send cods in my discord so I could probably help you with it:

EvilDevJxst#4503

1 Like