Script Won't Teleport Player When Timer Ends

i have an intermission script i made and it breaks because i’m trying to teleport the player to a spawn location

while wait() do

	if inRound == true then
		return
	end
	
	for i = 15, 0, -1 do
		status.Value = "Time Left: "..i
		wait(1.0)
	end

	intermissionSound:Stop()

	for _, plr in pairs(game.Players:GetPlayers()) do
		for _, spwn in pairs(workspace:WaitForChild("Map"):WaitForChild("PlayerSpawns"):GetChildren()) do
			plr.Character.PrimaryPart.CFrame = spwn.CFrame
		end
	end

here is a piece of the code (it’s not the whole thing, most of it’s just clutter)

while true do
    for index = 15, 0, -1 do
        status.Value  ="Time Left: " .. index
        task.wait(1)
    end

    for _, player in pairs(game.Players:GetPlayers()) do
       for _, spawn in pairs(workspace.Map.PlayerSpawns:GetChildren()) do
           player.Character.HumanoidRootPart.CFrame = spawn.CFrame
       end
    end
end

The code you sent in still broke the script

What I should I written in my reply was you need to set the HumanoidRootPart’s CFrame to the spawn’s CFrame so the entire character teleports to the spawn.

I’m not really getting the message

All good. You should teleport the player like this:

player.Character.HumanoidRootPart.CFrame = spawn.CFrame

do u want them to teleport in same spot?, in random spot?(may cause some of them to teleport in same spot) or them getting teleported to each spwn without causing them to overlap

no i want them to teleport to a spawn location when the timer ends

the script works perfectly fine if i make it break the characters joints or just leave out that part entirely

then i guess all in 1 spot

local spwn = --put the spawn part
local function TeleportFunc()
   for _, v in pairs(game.Players:GetChildren()) do
      v.Character.Humanoid.Sit = false
      v.Character:SetPrimaryPartCFrame(spwn.CFrame)
   end
end
TeleportrFunc() -- use this to call the function when u intermission done
1 Like

i’ll just post the whole script

local lobby = workspace.Lobby
local map = game.ReplicatedStorage.Maps.Map
local status = workspace.Values.Status
local inRound = workspace.Values.InRound

local intermissionSound = game.SoundService['2D'].Intermission
local backgroundSound = game.SoundService['2D'].Background

intermissionSound:Play()

while wait() do

	if inRound == true then
		return
	end
	
	for i = 15, 0, -1 do
		status.Value = "Time Left: "..i
		wait(1.0)
		
	end

	intermissionSound:Stop()

	for _, plr in pairs(game.Players:GetPlayers()) do
		plr.Character:BreakJoints()
		wait()
		
		local swordClone = game.ReplicatedStorage.Tools.ClassicSword:Clone()
		swordClone.Parent = plr.Backpack
	end

	local clone = map:Clone()
	clone.Parent = workspace

	inRound = true
	lobby:Destroy()

	local floorValue = workspace.Values.FloorValue
	floorValue.Value = floorValue.Value + 1

	local gui = game:GetService("StarterGui").UI.Intermission
	gui.Enabled = false

	local floorGui = game:GetService("StarterGui").UI.UI
	floorGui.Enabled = true
	
	backgroundSound:Play()
	
	script.Enabled = false
end




no it’s a folder of different spawns

thats what ive asked, if u want them to teleport in 1 spot, random spot(may cause to overlap character) or them having their own teleport target (but u need equal or more spwns than total players)

i’m sorry if i didn’t get your point earlier, i’ve been stuck on this all day

so random spot or each player have get to be sent to spot where there wont be other player teleported there

This might work for teleporting players to a random spawn

while true do
    for index = 15, 0, -1 do
        status.Value  ="Time Left: " .. index
        task.wait(1)
    end

    for _, player in pairs(game.Players:GetPlayers()) do
       local spawns = workspace.Map.PlayerSpawns:GetChildren()
       local randomSpawn = spawn[random.new(1, #randomSpawn)]

       player.Character.HumanoidRootPart.CFrame = randomSpawn.CFrame
    end
end

Yeah this didn’t work unfortunately :frowning_face:

i think i might just have it break its joints as before and make the respawn time faster

Ah that’s annoying.

I am not too sure what else to provide but there are some youtube videos out there that show you how to make an intermission system possibly even a system that shows you how to teleport players as well?

alright, i’ll take that into consideration. thanks for your time

1 Like

local Spwns = workspace.Folder:GetChildren()

local function Teleport()
	for i,v in pairs(game.Players:GetChildren()) do
		v.Character.Humanoid.Sit = false
		v.Character:SetPrimaryPartCFrame(Spwns[i].CFrame)
	end
end
Teleport()

call the Teleport() when u want them to teleport

note, the spwns folder must have equal or more children than players