So I have a gun that deals with manipulating the camera using mouse lock, but when I set the camera from custom to scriptable for another local script and try to switch back to custom the camera freezes and doesn’t turn at all anymore.
I’ve looked on the Forum to find solutions, but although some of them seem to work for others, I’m still unable to find a solution that works for me.
This part of the code works normally at first, and is able to mouselock and move the camera correctly:
if input.UserInputType == Enum.UserInputType.MouseButton2 then
if equipped then
if not shootAnim.IsPlaying then
if Settings.gtype == "Sniper" and tool:FindFirstChild("Scope") then
isAiming = true
_G.Aiming = true
UIS.MouseBehavior = Enum.MouseBehavior.Default
local gui = tool:WaitForChild("Scope"):Clone()
gui.Parent = player.PlayerGui
local guiTween = TweenService:Create(gui:FindFirstChild("Image"), TweenInfo.new(0.5), {ImageTransparency = 0})
guiTween:Play()
for _, v in pairs(character:GetDescendants()) do
if v:IsA("BasePart") then
v.Transparency = 1
end
end
aimAnim:Play(0.5, 1, 1)
local fovTween = TweenService:Create(camera, TweenInfo.new(0.5), {FieldOfView = Settings.Zoom})
fovTween:Play()
wait(0.1)
else
isAiming = true
_G.Aiming = true
UIS.MouseBehavior = Enum.MouseBehavior.Default
aimAnim:Play(0.5, 1, 1)
if Settings.Type ~= "Sniper" then
local fovTween = TweenService:Create(camera, TweenInfo.new(0.5), {FieldOfView = Settings.Zoom})
fovTween:Play()
end
wait(0.1)
end
end
end
end
but then when I run this part, and change the camera to scriptable it is unable to mouselock and move the camera at all:
cam.CameraType = Enum.CameraType.Scriptable
cam.FieldOfView = 50
cam.CameraSubject = workspace.Cutscene.changeRoom.changeDummy.Humanoid
cam.CFrame = workspace.Cutscene.changeRoom['changeCam'].CFrame