-- RIVALS-STYLE LOCK ON (FINAL – HIGHEST BODY TARGET FIX) local Players = game:GetService("Players") local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local player = Players.LocalPlayer local camera = workspace.CurrentCamera -------------------------------------------------- -- STATE -------------------------------------------------- local SPECTATING = false local currentTarget = nil local retargetTime = 2 local smoothness = 0.15 local lastUpdate = 0 -- NEW: Team check toggle local TEAM_CHECK_ENABLED = true -------------------------------------------------- -- CHARACTER HELPERS -------------------------------------------------- local function getChar() return player.Character or player.CharacterAdded:Wait() end local function getHumanoid(char) return char and char:FindFirstChildOfClass("Humanoid") end local function getRoot(char) return char and char:FindFirstChild("HumanoidRootPart") end -------------------------------------------------- -- GUI -------------------------------------------------- local gui = Instance.new("ScreenGui") gui.ResetOnSpawn = false gui.IgnoreGuiInset = true gui.Parent = player:WaitForChild("PlayerGui") local frame = Instance.new("Frame", gui) frame.Size = UDim2.new(0,300,0,260) frame.Position = UDim2.new(0,40,0,40) frame.BackgroundColor3 = Color3.fromRGB(25,25,25) frame.BorderSizePixel = 0 Instance.new("UICorner", frame).CornerRadius = UDim.new(0,12) -- TOP BAR (DRAG ONLY) local topBar = Instance.new("Frame", frame) topBar.Size = UDim2.new(1,0,0,30) topBar.BackgroundColor3 = Color3.fromRGB(35,35,35) topBar.BorderSizePixel = 0 local title = Instance.new("TextLabel", topBar) title.Size = UDim2.new(1,0,1,0) title.BackgroundTransparency = 1 title.Text = "LOCK ON" title.TextColor3 = Color3.new(1,1,1) title.Font = Enum.Font.GothamBold title.TextScaled = true -- DRAG LOGIC local dragging, dragStart, startPos topBar.InputBegan:Connect(function(i) if i.UserInputType == Enum.UserInputType.MouseButton1 then dragging = true dragStart = i.Position startPos = frame.Position end end) UserInputService.InputEnded:Connect(function(i) if i.UserInputType == Enum.UserInputType.MouseButton1 then dragging = false end end) UserInputService.InputChanged:Connect(function(i) if dragging and i.UserInputType == Enum.UserInputType.MouseMovement then local delta = i.Position - dragStart frame.Position = UDim2.new( startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y ) end end) -------------------------------------------------- -- TOGGLE BUTTON -------------------------------------------------- local toggle = Instance.new("TextButton", frame) toggle.Size = UDim2.new(1,-20,0,35) toggle.Position = UDim2.new(0,10,0,40) toggle.Text = "LOCK ON: OFF" toggle.Font = Enum.Font.GothamBold toggle.TextScaled = true toggle.BackgroundColor3 = Color3.fromRGB(0,170,255) toggle.TextColor3 = Color3.new(1,1,1) Instance.new("UICorner", toggle) local function updateToggle() toggle.Text = SPECTATING and "LOCK ON: ON" or "LOCK ON: OFF" end toggle.MouseButton1Click:Connect(function() SPECTATING = not SPECTATING updateToggle() end) -------------------------------------------------- -- TEAM CHECK TOGGLE (NEW) -------------------------------------------------- local teamToggle = Instance.new("TextButton", frame) teamToggle.Size = UDim2.new(1,-20,0,30) teamToggle.Position = UDim2.new(0,10,0,80) teamToggle.Text = "Team Check: ON" teamToggle.Font = Enum.Font.GothamBold teamToggle.TextScaled = true teamToggle.BackgroundColor3 = Color3.fromRGB(60,60,60) teamToggle.TextColor3 = Color3.new(1,1,1) Instance.new("UICorner", teamToggle) teamToggle.MouseButton1Click:Connect(function() TEAM_CHECK_ENABLED = not TEAM_CHECK_ENABLED teamToggle.Text = "Team Check: " .. (TEAM_CHECK_ENABLED and "ON" or "OFF") end) -------------------------------------------------- -- SLIDERS -------------------------------------------------- local function createSlider(text, yPos, min, max, default, callback) local label = Instance.new("TextLabel", frame) label.Position = UDim2.new(0,10,0,yPos) label.Size = UDim2.new(1,-20,0,20) label.Text = text label.TextColor3 = Color3.new(1,1,1) label.BackgroundTransparency = 1 label.Font = Enum.Font.Gotham label.TextScaled = true local bar = Instance.new("Frame", frame) bar.Position = UDim2.new(0,10,0,yPos+25) bar.Size = UDim2.new(1,-20,0,8) bar.BackgroundColor3 = Color3.fromRGB(60,60,60) bar.BorderSizePixel = 0 Instance.new("UICorner", bar) local knob = Instance.new("Frame", bar) knob.Size = UDim2.new(0,12,0,12) knob.AnchorPoint = Vector2.new(0.5,0.5) knob.Position = UDim2.new((default-min)/(max-min),0,0.5,0) knob.BackgroundColor3 = Color3.fromRGB(0,170,255) Instance.new("UICorner", knob) local dragging = false knob.InputBegan:Connect(function(i) if i.UserInputType == Enum.UserInputType.MouseButton1 then dragging = true end end) UserInputService.InputEnded:Connect(function(i) if i.UserInputType == Enum.UserInputType.MouseButton1 then dragging = false end end) UserInputService.InputChanged:Connect(function(i) if dragging and i.UserInputType == Enum.UserInputType.MouseMovement then local percent = math.clamp( (i.Position.X - bar.AbsolutePosition.X) / bar.AbsoluteSize.X, 0, 1 ) knob.Position = UDim2.new(percent,0,0.5,0) callback(min + (max-min)*percent) end end) end createSlider("Smoothness", 125, 0.05, 1, smoothness, function(v) smoothness = v end) createSlider("Retarget Time", 175, 0.5, 5, retargetTime, function(v) retargetTime = v end) -------------------------------------------------- -- KEYBIND (J) -------------------------------------------------- UserInputService.InputBegan:Connect(function(i,gp) if gp then return end if i.KeyCode == Enum.KeyCode.J then SPECTATING = not SPECTATING updateToggle() end end) -------------------------------------------------- -- TARGETING -------------------------------------------------- local function isAlive(plr) if not plr.Character then return false end local hum = getHumanoid(plr.Character) return hum and hum.Health > 0 end local function canTarget(plr) if not TEAM_CHECK_ENABLED then return true end if player.Team and plr.Team then return player.Team ~= plr.Team end return true end local function getNearestEnemy() local myRoot = getRoot(getChar()) if not myRoot then return end local closest, dist = nil, math.huge for _,plr in ipairs(Players:GetPlayers()) do if plr ~= player and isAlive(plr) and canTarget(plr) then local r = getRoot(plr.Character) if r then local d = (r.Position - myRoot.Position).Magnitude if d < dist then dist = d closest = plr end end end end return closest end -------------------------------------------------- -- CAMERA FOLLOW + LOCK ON (HIGHEST BODY TARGET) -------------------------------------------------- RunService:BindToRenderStep("RivalsLock", Enum.RenderPriority.Camera.Value + 20, function(dt) if not SPECTATING then return end local char = getChar() local root = getRoot(char) if not root then return end camera.CameraType = Enum.CameraType.Scriptable lastUpdate += dt if lastUpdate >= retargetTime or not currentTarget or not isAlive(currentTarget) then currentTarget = getNearestEnemy() lastUpdate = 0 end if currentTarget and currentTarget.Character then local targetChar = currentTarget.Character local targetPart = targetChar:FindFirstChild("Head") or targetChar:FindFirstChild("UpperTorso") or targetChar:FindFirstChild("LowerTorso") or targetChar:FindFirstChild("Torso") or getRoot(targetChar) if not targetPart then return end local camPos = root.Position + Vector3.new(0, 2, 0) camera.CFrame = camera.CFrame:Lerp( CFrame.new(camPos, targetPart.Position), smoothness ) end end)