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

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

Asked by 5 years ago

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

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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!

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 Odlnsonthor 11 — 5y
0
Kinda like a shift lock? Ziffixture 6913 — 5y
0
yes exactly Odlnsonthor 11 — 5y
0
Give me a second Ziffixture 6913 — 5y
View all comments (10 more)
0
and also when switched to fps mode you are able to aim down the sight/barrel and so on Odlnsonthor 11 — 5y
0
Sorry, I can't do that for you Ziffixture 6913 — 5y
0
I edited the answer, it may not work, but try Ziffixture 6913 — 5y
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 Odlnsonthor 11 — 5y
0
If not, there is a second fix, consider referencing the LocalPlayer and then saying Player.MaxZoomDistance/min Ziffixture 6913 — 5y
0
i dont really understand any of this seems i started scripting 3 days ago Odlnsonthor 11 — 5y
0
Does it work? I'll run you through on discord Ziffixture 6913 — 5y
0
yep Optix#6442 Odlnsonthor 11 — 5y
0
Sent Ziffixture 6913 — 5y
0
if it works then acceot the answer please;) Ziffixture 6913 — 5y
Ad

Answer this question