Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ctrl to aimbot
- -- GOOD FOR TSB TESTED IT LOL
- local UserInputService = game:GetService("UserInputService")
- local Players = game:GetService("Players")
- local camera = game.Workspace.CurrentCamera
- local isFacingLocked = false
- local isTyping = false
- local nearestPlayer = nil
- local function findNearestPlayer()
- local minDistance = math.huge
- local closestPlayer = nil
- local localPlayerPosition = Players.LocalPlayer.Character and Players.LocalPlayer.Character.HumanoidRootPart.Position
- if not localPlayerPosition then
- return nil
- end
- for _, player in pairs(Players:GetPlayers()) do
- if player ~= Players.LocalPlayer and player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
- local distance = (player.Character.HumanoidRootPart.Position - localPlayerPosition).magnitude
- if distance < minDistance then
- minDistance = distance
- closestPlayer = player
- end
- end
- end
- return closestPlayer
- end
- local function faceNearestPlayer()
- if isFacingLocked then
- nearestPlayer = findNearestPlayer()
- if nearestPlayer then
- local targetPosition = nearestPlayer.Character.HumanoidRootPart.Position
- local lookVector = (targetPosition - camera.CFrame.Position).unit
- camera.CFrame = CFrame.lookAt(camera.CFrame.Position, camera.CFrame.Position + lookVector)
- end
- end
- end
- UserInputService.InputBegan:Connect(function(input)
- if input.KeyCode == Enum.KeyCode.LeftAlt or input.KeyCode == Enum.KeyCode.RightAlt then
- isFacingLocked = not isFacingLocked
- if not isFacingLocked then
- nearestPlayer = nil
- end
- elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
- if isFacingLocked and not isTyping then
- faceNearestPlayer()
- end
- elseif input.UserInputType == Enum.UserInputType.TextBox and input.UserInputState == Enum.UserInputState.Begin then
- isTyping = true
- end
- end)
- UserInputService.InputChanged:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.TextBox then
- if input.UserInputState == Enum.UserInputState.End then
- isTyping = false
- end
- end
- end)
- game:GetService("RunService").RenderStepped:Connect(function()
- faceNearestPlayer()
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement