Can't move camera when my gun is equipped

I’m guessing it’s to do with setting the mouse behavior here:

game:GetService("RunService").RenderStepped:Connect(function()
	if not Check() then
		return
	end
	if SettingsAutomatic and Check() then
		if Button1Down and not DBShoot then
			Fire()
		end
	end

	local MouseBehavior = Enum.MouseBehavior.Default
	
	if Humanoid.CameraOffset.Magnitude>0 then
		MouseBehavior = Enum.MouseBehavior.LockCenter
	end

	if Shiftlock then
		local hrp = Character.HumanoidRootPart
		local dir = Camera.CFrame.LookVector*1000
		Character.HumanoidRootPart.CFrame = CFrame.lookAt(hrp.Position,Vector3.new(dir.X,hrp.Position.Y,dir.Z))
	end

	local o = Player.PlayerScripts.Viewmodel.Offset0

	o.Value=aimoffset.Value

	Camera.FieldOfView=FoV.Value

	if Character:FindFirstChild("Head").LocalTransparencyModifier >= 1 then
		FirstPerson = true
	else
		FirstPerson = false
	end

	if Shiftlock and not FirstPerson then
		MouseBehavior = Enum.MouseBehavior.LockCenter
		Humanoid.CameraOffset = Vector3.new(2,1,0)
	elseif not Shiftlock then
		Humanoid.CameraOffset = Vector3.new(0,0,0)
	end
	if FirstPerson then
		MouseBehavior = Enum.MouseBehavior.LockCenter
		Humanoid.CameraOffset = Vector3.new(0,0,0)
	end

	if UIS.MouseBehavior~=MouseBehavior then
		UIS.MouseBehavior = MouseBehavior
	end


end)

I’m not sure how to fix this though, considering I kinda of need it for shiftlock system.

2 Likes

Do you have a video of the issue? Would help.

Well, I mean you are locking the mouse and setting the cameraoffset constantly so i mean I guess that’s why?

when the mouse is even set to default, I can’t move my camera when holding MB2

It would be in roblox format and I don’t have game open right, now, but you know how you move camera when holding right click? well when I hold right click it doesn’t move camera even when I set the MouseBehavior to default if it neve changes

Did you change the camera type? It should be set to something like “fixed”, setting it to something like scriptable will make MB2 not work normally.

It’s on custom, which is default mode

I’m guessing it’s because you make the variable MouseBehavior and set it to Default. But no where in the code later on is it set back to default?

The MouseBehavior local is the UIS.MouseBehavior that it’s set to.

if UIS.MouseBehavior~=MouseBehavior then
		UIS.MouseBehavior = MouseBehavior
	end

When you’re in third person is the camera always offset from the default offset value?

1 Like