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)
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.