So I was gonna make it so when you press F on your keyboard it changes your cameraMode to either Locker or classic, only problem is I have to hold down the F button for it to stay in firstPerson, when I just want it so if you press it it locks you to first person, and if you press it again it turns it to classic.
How can I fix the problem?
local function handleInput(action)
if action == 'ChangeCamera' then
if player.CameraMode == Enum.CameraMode.LockFirstPerson then
player.CameraMode = Enum.CameraMode.Classic
else
player.CameraMode = Enum.CameraMode.LockFirstPerson
end
end
end
contextActionService:BindAction('ChangeCamera',handleInput,true,Enum.KeyCode.F,Enum.KeyCode.ButtonB)
And no there are no other scripts that effect the CameraMode
local function handleInput(action,state)
if action == 'ChangeCamera' and state.Name == "Begin" then
if player.CameraMode == Enum.CameraMode.LockFirstPerson then
player.CameraMode = Enum.CameraMode.Classic
else
player.CameraMode = Enum.CameraMode.LockFirstPerson
end
end
end
or you can just do this, so other actions dont have the same problem:
local function handleInput(action,state) if State.Name ~= "Begin" then return end
if action == 'ChangeCamera' then
if player.CameraMode == Enum.CameraMode.LockFirstPerson then
player.CameraMode = Enum.CameraMode.Classic
else
player.CameraMode = Enum.CameraMode.LockFirstPerson
end
end
end
You dont have to use State.Name, you can also do if State == Enum.UserInputState.Begin bla bla bla but I think it takes less space if you use .Name for it.