[Tutorial] How to tell if a player is on tablet or phone

Neat little detail I noticed is that the JumpButton has a consistent size for mobile and a seperate consistent size for tablet, however I have only tested this on robloxes Device Emulator so there may be inconsistencies with other devices!..?

Anyways if a player is on a mobile device then they will have a ScreenGui called “TouchGui” added to their PlayerGui folder ingame (under themselves in the Players folder)

From there you navigate under the TouchControlFrame frame and the Jump Button will be right there called JumpButton!

Alternatively you could just search up JumpButton in the explorer when playtesting in studio.

Now on phone the size is 70x70 pixels
And on tablet the size is 120x120 pixels

3 Likes

In PlayerModule.ControlModule.TouchJump:

local function ResizeJumpButton()
	local minAxis = math.min(self.parentUIFrame.AbsoluteSize.x, self.parentUIFrame.AbsoluteSize.y)
	local isSmallScreen = minAxis <= 500
	local jumpButtonSize = isSmallScreen and 70 or 120

	self.jumpButton.Size = UDim2.new(0, jumpButtonSize, 0, jumpButtonSize)
	self.jumpButton.Position = isSmallScreen and UDim2.new(1, -(jumpButtonSize*1.5-10), 1, -jumpButtonSize - 20) or
		UDim2.new(1, -(jumpButtonSize*1.5-10), 1, -jumpButtonSize * 1.75)
end

It’s just an arbitrary check. parentUIFrame is fullscreen.

2 Likes