RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"make a script that orbits a close opposite team player"
-- local script local player = game.Players.LocalPlayer local character = player.Character local humanoid = character:FindFirstChild("Humanoid") local rootPart = character:FindFirstChild("HumanoidRootPart") local radius = 10 while wait() do local closestDistance = math.huge local closestPlayer for _, otherPlayer in ipairs(game.Players:GetPlayers()) do if otherPlayer.TeamColor ~= player.TeamColor and otherPlayer.Character and otherPlayer.Character:FindFirstChild("HumanoidRootPart") then local distance = (otherPlayer.Character.HumanoidRootPart.Position - rootPart.Position).Magnitude if distance < closestDistance then closestDistance = distance closestPlayer = otherPlayer end end end if closestPlayer then local closestRootPart = closestPlayer.Character.HumanoidRootPart local angle = math.random() * math.pi * 2 local newPosition = closestRootPart.Position + Vector3.new(radius * math.cos(angle), 0, radius * math.sin(angle)) humanoid:MoveTo(newPosition) end end