game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(character) local char = plr.character or character print(char.Name) if MiniGameIsPlaying.Value == false then if game.Workspace:FindFirstChild("MainSpawn")then local MainIsland = game.Workspace:FindFirstChild("MainSpawn") local spawns = MainIsland.Spawns local randomSpawnNum = math.random(1,#spawns:GetChildren()) char:WaitForChild("HumanoidRootPart").CFrame = spawns:GetChildren()[randomSpawnNum].CFrame warn("YES") end elseif MiniGameIsPlaying.Value == true then if game.Workspace:FindFirstChild("SpecRoom")then local MainIsland = game.Workspace:FindFirstChild("SpecRoom") local spawns = MainIsland.Spawns local randomSpawnNum = math.random(1,#spawns:GetChildren()) char:FindFirstChild("HumanoidRootPart").CFrame = spawns:GetChildren()[randomSpawnNum].CFrame warn("NO") end end end) end)
It warns YES and NO but it dosen't teleport, Can someone help me?
It Turns out that I had to wait until the character was inserted into workspace
it turns out I had to replace the line:
local char = plr.character or character
With:
local char = game.Workspace:WaitForChild(character.Name) or character