How to force mobile players out of “portrait mode” view?

Whenever I start my game on mobile, I’m met with this:

How can I keep the screen in landscape mode?

6 Likes
if game:GetService('UserInputService').TouchEnabled == true then
	game:GetService('StarterGui').ScreenOrientation = Enum.ScreenOrientation.LandscapeRight
end```
1 Like

I’ve already tried that (sorry for not including in post, kinda forgot), and it doesn’t seem to have any effect.

Try this (in local script of course)

local guiService = game:GetService('StarterGui')

game:GetService('RunService').Heartbeat:Connect(function()
	if inputService.TouchEnabled == true then
		guiService.ScreenOrientation = Enum.ScreenOrientation.LandscapeRight
	end
end)

On an unrelated topic, Try using “UIAspectRatioConstraint” on your GUIs it will keep their shape no matter the screen size

1 Like

Tried that, still nothing. Starting to think it’s a game setting because it doesn’t look like this property does anything.

local guiService = game:GetService('StarterGui')
local inputService = game:GetService("UserInputService") 

game:GetService('RunService').Heartbeat:Connect(function()
	if inputService.TouchEnabled == true then
		guiService.ScreenOrientation = Enum.ScreenOrientation.LandscapeRight
	end
end)
1 Like

I accidentally cropped out “inputService” variable

This should work as I have used it in one of my previous projects

Alright, maybe it’s just something weird with my phone. Thanks for your help :slight_smile:

(Sorry for reviving this topic)

It would be inefficient if you want to set it every heartbeat.

You can just set StarterGuiScreenOrientation to Enum.ScreenOrientation.LandscapeRight within Studio instead of a script.

Even better if u set it to Enum.ScreenOrientation.LandscapeSensor

17 Likes

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