local player = game.Players.LocalPlayer tele = {"Tp1","Tp2","Tp3","Tp4","Tp5","Tp6","Tp7","Tp8","Tp9","Tp10","Tp11","Tp12","Tp13"} spawnz = game.Workspace.Spawnz:GetAllChildren() randomIndex = math.random(1,#tele) randomElement = tele[randomIndex] randomColor = BrickColor.new(randomElement) function SpawnPlayer() local torso = player:WaitForChild("Character") local torso = player.Character:WaitForChild("Torso") local spawnedIndex = math.random(1, #spawnz) randomElement = spawnedIndex() torso.CFrame = CFrame.new(spawn.Position + Vector3.new(0,3,0)) end player.Character.Humanoid.Died:connect(SpawnPlayer)
I don't know where this script should be plus what kind of script is it like local or none local script. I want the players to spawn in different spawn each time they die.
It should be in the workspace is this a free model or something you created if its a free model you need a model in the workspace named Spawnz with something actually in the model
This script is a LocalScript, but this code is very broken. A spawn-handling script should be a normal Script, and be in the ServerScriptService:
local Spawnz = Workspace.Spawnz:GetChildren() --Not GetAllChildren Game.Players.PlayerAdded:connect(function(player) local lastSpawn = nil player.CharacterAdded:connect(function(character) repeat local spawn = Spawnz[(math.random(1, #Spawnz)] until spawn ~= lastSpawn lastSpawn = spawn wait() --Let the Character fully load character.Torso.CFrame = spawn.CFrame + Vector3.new(0, 3, 0) end) end)
This should accomplish what I think you're trying to do.