How do when i press a key it makes me go First Person Mode? I will normally ask here for help in this website because i'm a new developer and i need help to start good with my game.
So i already have this scripts that i know in Starter Player Scripts, how do i continue?
local m = game.Players.LocalPlayer:GetMouse() db = true m.KeyDown:connect(function(k) k = k:lower() if k == "V" then if db == true then --FP Camera script goes here. end end end)
If you guys know, please help me.
Hey Pencil, You are on the right track. Try using this in the same location (LocalScript in StarterPlayerScripts)
local x = 13 --How far they can zoom out game.Players.LocalPlayer.CameraMaxZoomDistance = x local m = game.Players.LocalPlayer:GetMouse() m.KeyDown:Connect(function(k) k = k:lower() if k == "v" then if game.Players.LocalPlayer.CameraMode == Enum.CameraMode.Classic then print("First Person") game.Players.LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson else print("Third Person") game.Players.LocalPlayer.CameraMode = Enum.CameraMode.Classic game.Players.LocalPlayer.CameraMinZoomDistance = 10 game.Players.LocalPlayer.CameraMinZoomDistance = 0.5 end end end)
If this works, please accept my answer. If you need an explanation on how this works, don't hesitate to reply to this message. Thanks, LennyPlayzYT
Here is the code for to toggle 1st person mode:
local p = game.Players.LocalPlayer local m = p:GetMouse() local db = true local enabled = false m.KeyDown:Connect(function(k) if k:lower() == "v" then if db == true then if enabled == true then enabled = false p.CameraMode = Enum.CameraMode.Classic db = false wait(1) db = true else enabled = true p.CameraMode = Enum.CameraMode.LockFirstPerson db = false wait(1) db = true end end end end)