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

How do script a key to press that makes my character switch from third to 1st person view?

For an example in prison royale you can have your gun in third person with crosshair locked or have it in fps mode, i have tried making a script that changes camera angles but its just one big mess... ;( would anybody be able to help?

1 answer

For this to work properly, you're going to need two things UserInputService, and MaxZoomDistance, the first Service will allow us to Fire Events to Input related scenarios, and for the property, this allows us to restric their zooming ability, giving the impression of FirstPerson

local UserInputService = game:GetService("UserInputService")
local CamView = workspace.CurrentCamera.MaxZoomDistance
local CamView2 = workspace.CurrentCamera.MinZoomDistance
local ThirdP = 500
game.Players.PlayerAdded:Connect(function() --// As Player joins
   UserInputService.InputBegan:Connect(function(InputObject, GameProcessed)
      if not (GameProcessed) then --// if the Key was binded to any actions event; jumping typing then ignore
         if (InputObject.KeyCode == Enum.KeyCode.E) then --// KeyInput you desire
            CamView, CamView2= ThirdP
         end
      end
   end)
end)

Hope this helps! If so, don't forget to accept and upvote If there is anything confusing, please let me know!

14 comments

0

i mean like in prison royale you can have like third person lock so your crosshair in the middle of the screen is where shoot from like in fortnite but i want to be like when i press q on my keyboard i want it to switch to first person and be able to aim down the weapon sight

0

Kinda like a shift lock?

0

yes exactly

0

Give me a second

0

and also when switched to fps mode you are able to aim down the sight/barrel and so on

0

Sorry, I can't do that for you

0

I edited the answer, it may not work, but try

0

okay thank you very much man for your help, contact me on discord Optix#6442 if u wanna be part of my new game for front page

0

If not, there is a second fix, consider referencing the LocalPlayer and then saying Player.MaxZoomDistance/min

0

i dont really understand any of this seems i started scripting 3 days ago

0

Does it work? I'll run you through on discord

0

yep Optix#6442

0

Sent

0

if it works then acceot the answer please;)

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