respawn_time = .01 allow_force_respawn = false force_respawn = "rspwn" -------------------------------------------- game.Players.CharacterAutoLoads = false function onPlayerDied(player, character) wait(respawn_time) player:LoadCharacter() PlrPlrs = player.Name PlrWrkspac = game.Workspace:FindFirstChild("PlrPlrs") wait(1) if game.Workspace.StageNum.Value == 1 then PlrWrkspac:MoveTo(game.Workspace.S1Spawn.Position) elseif game.Workspace.StageNum.Value == 2 then PlrWrkspac:MoveTo(game.Workspace.S2Spawn.Position) end end function onPlayerSpawned(player, character) while not character:FindFirstChild("Humanoid") do wait() end character.Humanoid.Died:connect(function () onPlayerDied(player, character) end) end function onPlayerChatted(player, message, recipient) if message == force_respawn and allow_force_respawn then player:LoadCharacter() end end function onPlayerEntered(player) player.CharacterAdded:connect(function (char) onPlayerSpawned(player, char) end) player.Chatted:connect(function (msg, rec) onPlayerChatted(player, msg, rec) end) player:LoadCharacter() end game.Players.PlayerAdded:connect(onPlayerEntered)
How would I go about moving the Player to the stage spawns after they respawn?
function onPlayerDied(player) wait(respawn_time) player:LoadCharacter() wait() --Give the Character a moment to load. PlrWrkspac = player.Character wait(1) if game.Workspace.StageNum.Value == 1 then PlrWrkspac:MoveTo(game.Workspace.S1Spawn.Position + Vector3.new(0, 2.5)) elseif game.Workspace.StageNum.Value == 2 then PlrWrkspac:MoveTo(game.Workspace.S2Spawn.Position + Vector3.new(0, 2.5)) end end
function onPlayerSpawned(player, character) character:WaitForChild("Humanoid") character.Humanoid.Died:connect(function () onPlayerDied(player) end) end
The first function included your error. Basically, you were searching the Workspace for "PlrPlrs", not the string in the variable itself. Also, you don't need to do that, since you already have access to the Player object. I added some height to the MoveTo's target position so the Character doesn't get stuck inside the SpawnLocation.
For the second, I removed the busywait, and removed the second parameter from the onPlayerDied call, since it is never used.