I'm trying to make a ffa game but i can't find out how to teleport the players to a random location. someone please help me and tell me how please. this is a script i found on roblox wiki local oldMessage = "" local minPlayers = 3
function teleportAllPlayers() local target = CFrame.new(workspace.TeleportTarget.Position) for i, player in ipairs(game.Players:GetChildren()) do player.Character.Torso.CFrame = target + Vector3.new(0, i * 5, 0) player.Playing.Value = 1 --add an offset of 5 for each character end end
function message(message) if oldMessage ~= message then oldMessage = message print(message) end end
function playersCurrentlyPlaying() for i, player in ipairs(game.Players:GetChildren()) do if player.Playing.Value == 1 then return true end end return false end
game:GetService('Players').PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() player.Playing.Value = 0 end) end)
local playing = Instance.new("IntValue", player) playing.Value = 0 playing.Name = "Playing"
end)
while(true) do wait(10) if #game.Players:getPlayers() >= minPlayers then if playersCurrentlyPlaying() then message("Waiting for the current game to end...") else message("There are enough players for a new game! Teleporting...") wait(4) teleportAllPlayers() end else message("Waiting for more players...") end end
function teleportAllPlayers() local a = game.Players:GetChildren() for _,v in pairs (a) do if v.Character then v.Character.Torso.CFrame = CFrame.new(Vector3.new(math.random(1,100),math.random(1,100),math.random(1,100)),v.Character.Torso.Position) end end end