Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

thirdperson to firstperson back to thirdperson script not working?

Ok, so pretty much when i press H it does change me to firstpersonlock its just when i press H again it doesn't go back.

https://imgur.com/DlUIlJw

1 answer

✓ Accepted answer

You have to add a variable to toggle between the 2 states, right now the code is saying that pressing H will bring you to first person while pressing any other key will bring you to third person, as evident on your if else statement

local FirstPerson = false

function onKeyPress(inputObject, gp)
   if inputObject.KeyCode == Enum.KeyCode.H then
     if not FirstPerson then 
        FirstPerson = true
       game.Players.LocalPlayer.CameraMode = "LockFirstPerson"
      else 
       FirstPerson = false
       game.Players.LocalPlayer.CameraMode = "Classic"
    end
   end
end

game:GetService("UserInputService").InputBegan:Connect(OnKeyPress)
 

also put your code in code blocks in the future so people can just copy and paste your code and edit it from there

1 comment

0

Will do, thank you so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.