--!strict
function getClosestLobby(character: Model): Model?
local humanoid = character
:FindFirstChildOfClass("Humanoid")
local rootPart = humanoid and humanoid.RootPart
if not humanoid or not rootPart then
return nil
end
local closestLobby = nil :: Model?
local closestDistance = math.huge
for _, lobby in lobbiesFolder:GetChildren() do
if not lobby:IsA("Model") then
continue
end
local distance = (rootPartPosition - lobby:GetPivot().Position).Magnitude
if distance < closestDistance then
closestDistance = distance
closestLobby = lobby
end
end
return closestLobby
endStrict Luau
--!strict on every script, so type errors show up in the editor instead of in a live server.








