Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

thirdperson to firstperson back to thirdperson script not working?

Asked by 5 years ago

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

Log in to vote
0
Answered by
aazkao 787 Moderation Voter
5 years ago
Edited 5 years ago

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

0
Will do, thank you so much! RedDeadDevil1908 54 — 5y
Ad

Answer this question