Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Define the variables
- local player = game.Players.LocalPlayer
- local mouse = player:GetMouse()
- local camera = game.Workspace.CurrentCamera
- local isRightClicking = false
- local lockedPlayer = nil
- -- Function to make the camera look at a player's head
- local function LookAtHead(targetPlayer)
- local targetCharacter = targetPlayer.Character
- if targetCharacter then
- local targetHead = targetCharacter:FindFirstChild("Head")
- if targetHead then
- camera.CFrame = CFrame.new(camera.CFrame.p, targetHead.Position)
- end
- end
- end
- -- Listen for RightClick input
- mouse.Button2Down:Connect(function()
- isRightClicking = true
- local players = game.Players:GetPlayers()
- local localPlayerIndex = table.find(players, player)
- if localPlayerIndex then
- table.remove(players, localPlayerIndex)
- end
- if #players > 0 then
- local randomIndex = math.random(1, #players)
- lockedPlayer = players[randomIndex]
- LookAtHead(lockedPlayer)
- end
- end)
- mouse.Button2Up:Connect(function()
- isRightClicking = false
- lockedPlayer = nil
- end)
- -- Main loop to continuously look at the locked player's head
- while true do
- if isRightClicking and lockedPlayer then
- LookAtHead(lockedPlayer)
- end
- wait() -- Use the default wait time (60 times per second)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement