Disable Mobile Camera Rotation

Alright everyone, I am trying to make a system where i disable the mobile camera rotation for example if you tilt your phone the screen shifts, I dont want it to go vertical.

1 Like

So when you tilt your device and it switches to fit with it, you want to disable this?

game:GetService("StarterGui"):SetScreenOrientation(Enum.ScreenOrientation.Landscape) -- set landscape to the correct enum.

get the correct enum type from here

1 Like

SetScreenOrientation isnt a part of startergui.

my bad.


game:GetService("StarterGui").ScreenOrientation(Enum.ScreenOrientation.Landscape) -- set landscape to the correct enum.

19:08:18.495 ScreenOrientation is not a valid member of StarterGui “StarterGui” - Client - LocalScript:1

game:GetService("StarterGui"):ScreenOrientation(Enum.ScreenOrientation.Sensor) -- set landscape to the correct enum.

ScreenOrientation is a Property, not a Method.

Also, you change their ScreenOrientation through Player.PlayerGui, not StarterGui

Like mentioned above, you have to get the correct Enum Type for ScreenOrientation when referencing it.

Here’s an example of a function that changes everyone’s ScreenOrientation (Server Script):

local Players = game:GetService("Players")

local function setPlayersScreenOrientation(screenOrientation)
	for _, player in ipairs(Players:GetPlayers()) do -- loops through all players
		if player:FindFirstChild("PlayerGui") then -- checks if a PlayerGui exists
			player.PlayerGui.ScreenOrientation = screenOrientation -- sets it to the specified screenOrientation
		end
	end
end

setPlayersScreenOrientation(Enum.ScreenOrientation.Landscape)

Here’s an example of changing it just for your client only (LocalScript):

game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui").ScreenOrientation = Enum.ScreenOrientation.Landscape -- specify what ScreenOrientation do you want here
3 Likes

Changing it from startergui changes it for everyone and sets it as the default.

thank you so much it works locally all I did was put the local script in starter gui!

Changing it from StarterGui does not change it for everyone. It will only change it to new players, however, existing players will not be changed.

1 Like

It updates for everyone in the game already, It only won’t update for everyone if its done from a local script.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.