Whenever I start my game on mobile, I’m met with this:
How can I keep the screen in landscape mode?
if game:GetService('UserInputService').TouchEnabled == true then
game:GetService('StarterGui').ScreenOrientation = Enum.ScreenOrientation.LandscapeRight
end```
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
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)
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
(Sorry for reviving this topic)
It would be inefficient if you want to set it every heartbeat.
You can just set StarterGui → ScreenOrientation to Enum.ScreenOrientation.LandscapeRight within Studio instead of a script.
Even better if u set it to Enum.ScreenOrientation.LandscapeSensor
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.