Hi, so I want the camera locked in first person, but when the player presses “C” it unlocks the camera and are forced out of first person and can move the mouse freely. It’s not working. The script gives no errors and goes through the entire code but it doesn’t even do anything. Here is my current code:
local plr = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local count = 0
print("set variables")
UIS.InputBegan:Connect(function(input)
print("made func")
if input.KeyCode == Enum.KeyCode.C and count == 0 then
plr.CameraMinZoomDistance = 3
count = 1
elseif count == 1 and input.KeyCode == Enum.KeyCode.C then
plr.CameraMinZoomDistance = 0.5
count = 0
end
print("did everything")
end)
Well if count is only 1 or 0 you might as well use a bool value for count
local plr = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local count = false
--print("set variables")
UIS.InputBegan:Connect(function(input,gp)
--print("made func")
if input.KeyCode == Enum.KeyCode.C and not count and not gp then -- First-person on
plr.CameraMinZoomDistance = 3
plr.CameraMode = Enum.CameraMode.LockFirstPerson
count = true
elseif input.KeyCode == Enum.KeyCode.C and count and not gp then -- First-person off
plr.CameraMode = Enum.CameraMode.Classic
plr.CameraMinZoomDistance = 0.5
count = false
end
--print("did everything")
end)
Works except when I press C I want the camera to FORCE the player in third person. I don’t want the player to scroll out I just want it to force it out.