ScreenOrientation not locking on mobile

Reproduction Steps
Put this in a LocalScript and run the game in a mobile:

game:GetService("StarterGui").ScreenOrientation = Enum.ScreenOrientation.LandscapeLeft

Expected Behavior
The game orientation should be locked in Landscape mode.

Actual Behavior
The orientation is not locked, ie, when rotating the mobile device, it’s entering in Portrait mode also.

Issue Area: Engine
Issue Type: Display
Impact: High
Frequency: Constantly

2 Likes

Can reproduce on a Samsung Galaxy S20FE running the latest version of roblox. Didn’t try putting it in a renderstepped function though.

1 Like

This is intended behaviour as setting the orientation of StarterGui only affects new players (as stated in the documentation), you should instead run this code:

game.Players.LocalPlayer.PlayerGui.ScreenOrientation = Enum.ScreenOrientation.LandscapeLeft

When a Player joins the game, if they are using a mobile device, this property will determine the device’s starting orientation. - StarterGui | Roblox Creator Documentation

@rogeriodec_games

No, it’s not:

Also…

image

If you know how to prevent the game from switching to Portrait, please show us.

Changing this property will not change the ScreenOrientation for Players already in the game. To change the orientation for an existing player use their PlayerGui.ScreenOrientation property. (StarterGui | Roblox Creator Documentation)

Also sorry, the code is actually:

game.Players.LocalPlayer.PlayerGui.ScreenOrientation = Enum.ScreenOrientation.LandscapeLeft
4 Likes

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