Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to always be locked onto a player's head?

I'm making a developer-only aimbot script for my own game so that devs can have special powers. I have this code:

local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable

camera.CFrame=
CFrame.new(camera.CFrame.Position,closestPlayer.Character.Head.Position)

The end result is something weird and hard to explain and it just doesn't work. I want to know how to make it so that I am in first person and the middle of my screen is locked on to the player's head but I can move around normally. Thanks in advance!

1 comment

0

use the Z coordinate

1 answer

✓ Accepted answer
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable



while wait()do
	local cframe = CFrame.new(game.Players.LocalPlayer.Character.Head.Position ,workspace.Dummy.UpperTorso.Position)
	camera.CFrame= cframe + (cframe.LookVector*2)
end	

This discussion is preserved as it was. New answers, comments, and votes are closed.