I have a third person camera, and it currently locks the player from zooming in or out, and it also makes the person follow where the mouse is going. What i need now is to make the mouse lock at one position on the screen. How would i start ? Here is the Cam script
local abs = math.abs
local distance = 5
local zoom = 70
local sensitivity = 0.25
local height = 1
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local camera = Workspace.CurrentCamera
while not camera do
Workspace.Changed:wait()
camera = Workspace.CurrentCamera
end
while not mouse do
wait(0.5)
mouse = player:GetMouse()
end
wait()
local char = true
local gyro, head, torso
camera.CameraType = "Scriptable"
camera.FieldOfView = zoom
while wait() do
if char ~= player.Character then
char = player.Character
while not char do
char = player.CharacterAdded:wait()
end
torso = char:WaitForChild "Torso"
head = char:WaitForChild "Head"
gyro = torso:FindFirstChild "lookatmouse" or Instance.new "BodyGyro"
gyro.maxTorque = Vector3.new(0, 7000, 0)
gyro.cframe = CFrame.new(0, 0, 1) + torso.Position
gyro.Name = "lookatmouse"
gyro.Parent = torso
end
local hit = mouse.Hit
if mouse.Hit.p.magnitude ~= 0 then
local objhit = torso.CFrame:pointToObjectSpace(hit.p)
local pos = head.Position + Vector3.new(0, height, 0)
local focus = CFrame.new(pos)
local vec
if abs(objhit.x) > objhit.z and
(objhit.x/objhit.y)^2 + (objhit.z/objhit.y)^2 > 1 then
vec = mouse.Hit.p - pos
else
vec = camera.CoordinateFrame.lookVector
end
pos = pos - vec.unit * distance
camera:Interpolate(
CFrame.new(
pos,
vec + pos
),
focus,
sensitivity
)
gyro.cframe = mouse.Hit
end
end
