Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I fix my obby stages to when I die I don't spawn at the very beginning?

The stage script is fully functional, no problems whatsoever. However, whenever I die I spawn at the very beginning instead of the stage you're supposed to be on. Any help is appreciated! :)

Here is the script for the stages

local Players = game:GetService("Players")

local Levels = workspace.Levels

Players.PlayerAdded:Connect (function(plr) local leaderstats = Instance.new("Folder") leaderstats.Parent = plr leaderstats.Name = "leaderstats"

local Level = Instance.new("IntValue")
Level.Name = "Level"
Level.Value = 0
Level.Parent = leaderstats

end)

for i = 1, #Levels:GetChildren() do local CurrentLevel = Levels:FindFirstChild(tostring(i)) CurrentLevel.Touched:Connect (function(part) local Player = Players:GetPlayerFromCharacter(part.Parent) if Player then if (Player.leaderstats.Level.Value + 1) == i then Player.leaderstats.Level.Value = i elseif Player.leaderstats.Level.Value < i then Player.Character.HumanoidRootPart.Position = Levels:FindFirstChild(tostring(Player.leaderstats.Level.Value)).Position + Vector3.new(0,3.5,0) end end end) end

2 comments

0

Could you include the scripts that deal with respsawning and/or the stages?

0

Sure! I just updated it.

1 answer

Instead of trying a complicated way a simple way is to give all ur stages a name like Stage1 Stage2 Stage3 and then put a tp script in the serverscriptservice saying this and put a folder in workspace for stages

game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(chr)
local Name = "Stage"..plr.leaderstats.Level.Value
local Stage = game.Workspace.Stages:FindFirstChild(Stage)
chr.HumanoidRootPart.CFrame = Stage.CFrame * CFrame.new(0,3,0)
end)
end)

I tested this script before it doesnt work in studio but it works in publish version

This discussion is preserved as it was. New answers, comments, and votes are closed.