Am I detecting mobile devices correctly?

Just to make sure, am I detecting if the player is on mobile correctly?

local function checkIfMobile()
	if UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled and not UserInputService.MouseEnabled then
		return true
	elseif not UserInputService.TouchEnabled and UserInputService.KeyboardEnabled and UserInputService.MouseEnabled then
		return false
	else
		return false
	end
end

RunService.Heartbeat:Connect(function()
	local result = checkIfMobile()
	gui.Enabled = result
end)

This is for a shift to sprint button.

1 Like

Mhm yes that is correct boo! Your code you provided is designed to detect whether the player is on a mobile device or not Xx :kiss:

2 Likes

This is so nerdy, just check for a screen gui called “TouchGui” if there is then they’re on mobile, else they’re on another device

Also use contextaspectservice for those type of stuff its much easier

2 Likes

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