local Players = game:GetService("Players") local RunService = game:GetService("RunService") local LocalPlayer = Players.LocalPlayer local function getNearestPlayer() local myChar = LocalPlayer.Character if not myChar or not myChar:FindFirstChild("HumanoidRootPart") then return nil end local myPos = myChar.HumanoidRootPart.Position local nearest local shortest = math.huge for _, player in ipairs(Players:GetPlayers()) do if player ~= LocalPlayer and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then local pos = player.Character.HumanoidRootPart.Position local dist = (pos - myPos).Magnitude if dist < shortest then shortest = dist nearest = player end end end return nearest end local function stickToBack(target) local myChar = LocalPlayer.Character local myRoot = myChar and myChar:FindFirstChild("HumanoidRootPart") local targetRoot = target and target.Character and target.Character:FindFirstChild("HumanoidRootPart") if not (myRoot and targetRoot) then return end if myChar:FindFirstChild("FollowConnection") then myChar.FollowConnection:Disconnect() myChar.FollowConnection:Destroy() end local conn = Instance.new("BindableEvent", myChar) conn.Name = "FollowConnection" RunService.Heartbeat:Connect(function() if not target or not target.Character or not target.Character:FindFirstChild("HumanoidRootPart") then conn:Destroy() return end local targetRoot = target.Character.HumanoidRootPart local backOffset = targetRoot.CFrame.LookVector * -3 myRoot.CFrame = CFrame.new(targetRoot.Position + backOffset) * CFrame.Angles(0, targetRoot.Orientation.Y, 0) end) local humanoid = target.Character:FindFirstChildOfClass("Humanoid") if humanoid then humanoid.Died:Connect(function() conn:Destroy() task.wait(2) local newTarget = getNearestPlayer() if newTarget then stickToBack(newTarget) end end) end end local function startFollowing() while task.wait(0.1) do local target = getNearestPlayer() if target then stickToBack(target) end end end LocalPlayer.CharacterAdded:Connect(function() task.wait(0.1) startFollowing() end) if LocalPlayer.Character then startFollowing() end