This was reposted from the discord server due to not getting an answer. :P I got some help with a function to teleport players into a map if they are touching a part:
local function teleportToGame() local partsInRegion = game.Workspace:FindPartsInRegion3(tpRegion, nil, math.huge) -- Region, Instance to ignore, maximum part count for _, part in ipairs(partsInRegion) do -- Iterating through the array returned local player = game.Players:GetPlayerFromCharacter(part.Parent) if player then -- if player player.Character.HumanoidRootPart.CFrame = game.Workspace.gameTeleport.CFrame + Vector3.new(math.random(3,6),math.random(3,6),math.random(3,6)) workspace.gameGui:Clone().Parent = player:FindFirstChild("PlayerGui") end end end
So I decided to try to reverse engineer the script to make it that if no-one is in the map, the round will end:
local partsInRegion = game.Workspace:FindPartsInRegion3(mapRegion, nil, math.huge) for _, part in ipairs(partsInRegion) do local player = game.Players:GetPlayerFromCharacter(part.Parent) if player then repeat wait() until player == nil end end
But it just keeps the round going, even if there is no-player inside it. Does anyone know what I might be doing wrong? thanks.