This is my code but I don't know why it is not working
if game.Players.NumPlayers < 4 then
local spawns = game.workspace.Wait:WaitForChild('waiting'):GetChildren() for _, player in pairs(game.Players:GetPlayers()) do if player and #spawns > 0 then local head = player.Character:WaitForChild('Head') local allspawns = math.random(1, #spawns) local randomspawn = spawns[allspawns] if randomspawn and head then head.CFrame = CFrame.new(randomspawn.Position + Vector3.new(0,2,0)) end end end end
Note: Create a local script in StaterPack or StarterGui.
I've tried to base this of the code example you gave above.
local player = game.Players.LocalPlayer local spawns = game.workspace.Wait:WaitForChild('waiting'):GetChildren() local head = player.Character:WaitForChild('Head') local allspawns = math.random(1, #spawns) local randomspawn = spawns[allspawns] if randomspawn and head then head.CFrame = CFrame.new(randomspawn.Position + Vector3.new(0, 2, 0)) end end