-- OneScriptFollower.lua -- Works in your own Roblox Studio game only. local Players = game:GetService("Players") local RunService = game:GetService("RunService") local UIS = game:GetService("UserInputService") local LocalPlayer = Players.LocalPlayer math.randomseed(tick()) -- === Helper Functions === local function getValidTargets() local list = {} for _, p in ipairs(Players:GetPlayers()) do if p ~= LocalPlayer and p.Character and p.Character:FindFirstChild("HumanoidRootPart") then local hum = p.Character:FindFirstChild("Humanoid") if hum and hum.Health > 0 then table.insert(list, p) end end end return list end local function pickRandomTarget() local list = getValidTargets() if #list == 0 then return nil end return list[math.random(1, #list)] end -- === GUI Setup === local playerGui = LocalPlayer:WaitForChild("PlayerGui") local screenGui = Instance.new("ScreenGui") screenGui.Name = "FollowerGUI" screenGui.ResetOnSpawn = false screenGui.Parent = playerGui local frame = Instance.new("Frame") frame.Size = UDim2.new(0, 300, 0, 100) frame.Position = UDim2.new(0.5, -150, 0.85, -50) frame.BackgroundColor3 = Color3.fromRGB(30, 30, 30) frame.BackgroundTransparency = 0.1 frame.BorderSizePixel = 0 frame.Parent = screenGui -- Title Bar (for dragging + minimize) local titleBar = Instance.new("Frame") titleBar.Size = UDim2.new(1, 0, 0, 25) titleBar.BackgroundColor3 = Color3.fromRGB(20, 20, 20) titleBar.BorderSizePixel = 0 titleBar.Parent = frame local titleLabel = Instance.new("TextLabel") titleLabel.Size = UDim2.new(1, -25, 1, 0) titleLabel.Position = UDim2.new(0, 5, 0, 0) titleLabel.BackgroundTransparency = 1 titleLabel.Text = "Follower GUI" titleLabel.TextColor3 = Color3.new(1, 1, 1) titleLabel.TextXAlignment = Enum.TextXAlignment.Left titleLabel.Parent = titleBar local minimizeButton = Instance.new("TextButton") minimizeButton.Size = UDim2.new(0, 25, 1, 0) minimizeButton.Position = UDim2.new(1, -25, 0, 0) minimizeButton.BackgroundColor3 = Color3.fromRGB(50, 50, 50) minimizeButton.Text = "-" minimizeButton.TextColor3 = Color3.new(1, 1, 1) minimizeButton.Parent = titleBar -- Buttons local contentFrame = Instance.new("Frame") contentFrame.Size = UDim2.new(1, 0, 1, -25) contentFrame.Position = UDim2.new(0, 0, 0, 25) contentFrame.BackgroundTransparency = 1 contentFrame.Parent = frame local prevBtn = Instance.new("TextButton") prevBtn.Size = UDim2.new(0.45, 0, 0.6, 0) prevBtn.Position = UDim2.new(0.03, 0, 0.25, 0) prevBtn.Text = "Previous" prevBtn.BackgroundColor3 = Color3.fromRGB(255, 100, 100) prevBtn.TextColor3 = Color3.new(1, 1, 1) prevBtn.Parent = contentFrame local nextBtn = Instance.new("TextButton") nextBtn.Size = UDim2.new(0.45, 0, 0.6, 0) nextBtn.Position = UDim2.new(0.52, 0, 0.25, 0) nextBtn.Text = "Next" nextBtn.BackgroundColor3 = Color3.fromRGB(100, 255, 100) nextBtn.TextColor3 = Color3.new(0, 0, 0) nextBtn.Parent = contentFrame local label = Instance.new("TextLabel") label.Size = UDim2.new(1, 0, 0.25, 0) label.Position = UDim2.new(0, 0, -0.15, 0) label.BackgroundTransparency = 1 label.Text = "Target: none" label.TextColor3 = Color3.new(1, 1, 1) label.TextScaled = true label.Parent = contentFrame -- === Dragging Logic === local dragging = false local dragStart, startPos local function updateDrag(input) local delta = input.Position - dragStart frame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y) end titleBar.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then dragging = true dragStart = input.Position startPos = frame.Position input.Changed:Connect(function() if input.UserInputState == Enum.UserInputState.End then dragging = false end end) end end) UIS.InputChanged:Connect(function(input) if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then updateDrag(input) end end) -- === Minimize Logic === local minimized = false minimizeButton.MouseButton1Click:Connect(function() minimized = not minimized if minimized then contentFrame.Visible = false frame.Size = UDim2.new(0, 300, 0, 25) minimizeButton.Text = "+" else contentFrame.Visible = true frame.Size = UDim2.new(0, 300, 0, 100) minimizeButton.Text = "-" end end) -- === Follow Logic === local following = false local targetPlayer = nil local hbConn, targetDiedConn, targetRemoveConn local function cleanup() if hbConn then hbConn:Disconnect() hbConn = nil end if targetDiedConn then targetDiedConn:Disconnect() targetDiedConn = nil end if targetRemoveConn then targetRemoveConn:Disconnect() targetRemoveConn = nil end end local function stopFollowing() following = false targetPlayer = nil label.Text = "Target: none" cleanup() end local function follow(target) if not target or not target.Character or not target.Character:FindFirstChild("HumanoidRootPart") then stopFollowing() return end targetPlayer = target following = true label.Text = "Target: " .. target.Name cleanup() local hum = target.Character:FindFirstChild("Humanoid") if hum then targetDiedConn = hum.Died:Connect(function() wait(0.2) local newTarget = pickRandomTarget() if newTarget then follow(newTarget) else stopFollowing() end end) end targetRemoveConn = target.AncestryChanged:Connect(function(_, parent) if not parent then local newTarget = pickRandomTarget() if newTarget then follow(newTarget) else stopFollowing() end end end) local offset = CFrame.new(2, 0, 0) hbConn = RunService.Heartbeat:Connect(function() if not following or not targetPlayer then return end local myChar = LocalPlayer.Character local tChar = targetPlayer.Character if not myChar or not tChar then stopFollowing() return end local myHRP = myChar:FindFirstChild("HumanoidRootPart") local tHRP = tChar:FindFirstChild("HumanoidRootPart") if not myHRP or not tHRP then stopFollowing() return end myHRP.CFrame = myHRP.CFrame:Lerp(tHRP.CFrame * offset, 0.6) end) end nextBtn.MouseButton1Click:Connect(function() local t = pickRandomTarget() if t then follow(t) else label.Text = "Target: none (no players)" end end) prevBtn.MouseButton1Click:Connect(stopFollowing) -- === Reset on Death Logic === local function onCharacterAdded(char) local hum = char:WaitForChild("Humanoid") hum.Died:Connect(function() stopFollowing() task.wait(3) -- optional short delay LocalPlayer:LoadCharacter() end) end onCharacterAdded(LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()) LocalPlayer.CharacterAdded:Connect(onCharacterAdded)