Hello, so, i've been trying to integrate this camera script into a tool, and as I was bug testing, I noticed that when I press 'o' or scroll to try and zoom out, it unlocks the mouse. Code:
tool.Equipped:Connect(function()
plr.CameraMaxZoomDistance = 8
camera.CameraType = Enum.CameraType.Scriptable
is.MouseBehavior = Enum.MouseBehavior.LockCenter
is.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
xAngle = xAngle-input.Delta.x*0.4
--Clamp the vertical axis so it doesn't go upside down or glitch.
yAngle = math.clamp(yAngle-input.Delta.y*0.4,-80,80)
end
end)
stepped = run.RenderStepped:Connect(function()
local Character = plr.Character
local rootPart = Character:FindFirstChild("HumanoidRootPart")
if Character and rootPart then
--Set rotated start cframe inside head
local startCFrame = CFrame.new((rootPart.CFrame.p + Vector3.new(0,2,0)))*CFrame.Angles(0, math.rad(xAngle), 0)*CFrame.Angles(math.rad(yAngle), 0, 0)
--Set camera focus and cframe
local cameraCFrame = startCFrame + startCFrame:vectorToWorldSpace(Vector3.new(cameraPos.X,cameraPos.Y,cameraPos.Z))
local cameraFocus = startCFrame + startCFrame:vectorToWorldSpace(Vector3.new(cameraPos.X,cameraPos.Y,-50000))
camera.CFrame = CFrame.new(cameraCFrame.p,cameraFocus.p)
end
end)
print("Equipped")
equip:Play()
end)
Is there a specific reason this is happening? (is is input service)
