Orbit

Run Settings
LanguageLua
Language Version
Run Command
getgenv().toggleKey = "X" if executed then return end if not highlight then getgenv().highlight = Instance.new("Highlight") highlight.Enabled = false highlight.FillColor = Color3.fromRGB(25, 255, 25) highlight.OutlineColor = Color3.fromRGB(0, 255, 0) highlight.Parent = game:GetService("CoreGui") end local userInputService = game:GetService("UserInputService") local runService = game:GetService("RunService") local players = game:GetService("Players") local plr = players.LocalPlayer local speed = 10 local radius = 5 local toggled = false local connection: RBXScriptConnection = nil local function getCharacter(player): Model player = player or plr return player.Character or player.CharacterAdded:Wait() end local function getRootPart(player): Part player = player or plr return player:FindFirstChild("HumanoidRootPart") or getCharacter(player):WaitForChild("HumanoidRootPart") end local function getRootPosition(player): Vector3 player = player or plr return getRootPart(player).Position end local function getDirection(partA, partB): Vector3 return (partA.Position - partB.Position).Unit end local function getGun(player) player = player or plr return getCharacter(player):FindFirstChildOfClass("Tool") end local function getGunRemote(player) player = player or plr local gun = getGun(player) return gun ~= nil and gun:WaitForChild("Fire") end local function fireGun(hitPosition) local remote = getGunRemote() if remote then remote:FireServer(hitPosition) end end local function orbit(target) local char = getCharacter() local targetChar = getCharacter(target) if not targetChar or not char then return end local root = getRootPart() local targetRoot = getRootPart(target) if connection then connection:Disconnect() connection = nil end connection = runService.Heartbeat:Connect(function() if not targetChar or not targetChar.Parent then if connection then connection:Disconnect() connection = nil end return end if not char or not char.Parent then if connection then connection:Disconnect() connection = nil end return end highlight.Adornee = targetChar highlight.Enabled = true local offsetX = math.sin(tick() * speed) * radius local offsetZ = math.cos(tick() * speed) * radius local offset = Vector3.new(offsetX, 0, offsetZ) root.CFrame = CFrame.new(targetRoot.Position + offset, targetRoot.Position) fireGun(targetRoot.CFrame * CFrame.new(0, 0.7, 0) + (targetRoot.Velocity / 10)) end) end local function getTarget(): Player local distance = math.huge local target = nil for _, tempTarget in next, players:GetPlayers() do local character = getCharacter() local targetChar = getCharacter(target) if not character or not targetChar then continue end local rootPos = getRootPosition() local targetPos = getRootPosition(target) local tempDist = (rootPos - targetPos).Magnitude if tempDist < distance then distance = tempDist target = tempTarget end end return target end userInputService.InputBegan:Connect(function(key: InputObject, gpe: boolean) if gpe then return end if key.KeyCode == Enum.KeyCode[toggleKey] then toggled = not toggled if toggled then local target = getTarget() orbit(target) elseif not toggled then highlight.Adornee = nil highlight.Enabled = false if connection then connection:Disconnect() connection = nil end end end end) getgenv().executed = true print("LOADED")
Editor Settings
Theme
Key bindings
Full width
Lines