Camera mode issue

I don’t really know how to use Player.cameramode do I have to run it on the server?

Here is my code

local Player = game:GetService("Players").LocalPlayer
local Uis = game:GetService("UserInputService")

local firstperson = true

Uis.InputBegan:Connect(function(input, g)
	if g then return else end

	if input.KeyCode == Enum.KeyCode.Q then
		if firstperson then
			firstperson = false
			Player.CameraMode = Enum.CameraMode.Classic
			print("Third person")
		else
			firstperson = true
			Player.CameraMode = Enum.CameraMode.LockFirstPerson
			print("First person")
		end
	end
end)

I can’t zoom out even when I press q

4 Likes
local Player = game:GetService("Players").LocalPlayer
local Uis = game:GetService("UserInputService")


Uis.InputBegan:Connect(function(input, g)
	if g then return else end

	if input.KeyCode == Enum.KeyCode.Q then
		if Player.CameraMode = Enum.CameraMode.Classic then
			Player.CameraMode = Enum.CameraMode.LockFirstPerson
		else
			Player.CameraMode = Enum.CameraMode.Classic
		end
	end
end)
2 Likes

I tried changing the camera mode with any uis and it still didn’t work

what error are u getting though?

1 Like

reference the currentcamera, like this:
local camera = workspace.CurrentCamera
and then you can do cameramode

mind explaining how that could fix the issue? isn’t cameramode a proprety of the player instance and not the current camera? i’m very intrested!

2 Likes

I’m not getting an error thats the issue

oh, my bad. didnt read it the post correctly lol

local Player = game:GetService("Players").LocalPlayer
local Uis = game:GetService("UserInputService")


Uis.InputBegan:Connect(function(input, g)
	if g then return else end

	if input.KeyCode == Enum.KeyCode.Q then
		if Player.CameraMode == Enum.CameraMode.Classic then
			Player.CameraMode = Enum.CameraMode.LockFirstPerson
		else
			Player.CameraMode = Enum.CameraMode.Classic
		end
	end
end)
1 Like

misspelled stuff in the code i gave u earlier

though what type of issue are u facing rn, u need to give context

try removing the gameprocessed line of code, since unless i remember incorrectly, it should be the opposite
someone correct me if im wrong tho

in the properties tab it says its changing but its not

is it a script or local script

maybe try changing it server side?

game proceed checks if the player is typing in the chat

1 Like

if that doesn’t work than i have a work around

Client

local Player = game:GetService("Players").LocalPlayer
local Uis = game:GetService("UserInputService")
local Remote = game:GetService("ReplicatedStorage").RemoteEvent


Uis.InputBegan:Connect(function(input, g)
	if g then return else end

	if input.KeyCode == Enum.KeyCode.Q then
		if Player.CameraMode == Enum.CameraMode.Classic then
			Remote:FireServer(Enum.CameraMode.LockFirstPerson)
		else
			Remote:FireServer(Enum.CameraMode.Classic)
		end
	end
end)

Server

local Remote = game:GetService("ReplicatedStorage").RemoteEvent

Remote.OnServerEvent:Connect(function(Player, Mode)
	Player.CameraMode = Mode
end)```


---Doesn't work

cameramode should be working without replicating to the client… maybe try changing the line if g then return else end to
if g then return end

I tried that it got past the if statement even with the else to