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

1st person to 3rd person?

Hi! So I know how to make it that a player can zoom from 1st person to 3rd person but my question is how would I make it so if the player hits a letter like "t' they can switch views?

5 comments

0

So you want the code for pressing the button?

2

is Scripting Helpers = sCRIPTING mAKERS?

0

I sure hope not...

0

No I know the script but I want to know how to switch views when I hit a button

0

Please Accept my answer if it helps! It also gives you reputation so you don't get suspended.

1 answer

There is a feature called "LockFirstPerson". You could also use UserInputService to see if they pressed a key


#UserInputService UserInputService acts like KeyDown but it isn't actually deprecated and it takes ANY type of input(Clicking, Chatting, Etc).

local uis = game:GetService("UserInputService")

uis.InputBegan:connect(function(input, chat)
	if input.KeyCode == Enum.KeyCode.T and not chat then --If they press T and is not chatting/typing into a textbox then...
		print("Pressed T!")
	end
end)

#CameraMode A players has something called CameraMode. There is Classic(Third Person) and LockFirstPerson(1st person obviously.)

game:GetService("Players").LocalPlayer.CameraMode = Enum.CameraMode.LockFirstPerson
wait(3)
game:GetService("Players").LocalPlayer.CameraMode = Enum.CameraMode.Classic


#Final Product

--LocalScript
local uis = game:GetService("UserInputService")
local plyr = game:GetService("Players").LocalPlayer

uis.InputBegan:connect(function(input, chat)
	if input.KeyCode == Enum.KeyCode.T and not chat then
		if plyr.CameraMode == Enum.CameraMode.Classic then
			plyr.CameraMode = Enum.CameraMode.LockFirstPerson
		else
			plyr.CameraMode = Enum.CameraMode.Classic
		end
	end
end)



Hope it helps!

1 comment

0

Thank you very much! This was helpful!

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