Like, for example. If I have a mouse over event. Then that wont work with mobile. Is there a way to detect if a user is mobile or desktop?
And I could have certain functions run if either is detected? Or how do you go about dealing with this?
Like, for example. If I have a mouse over event. Then that wont work with mobile. Is there a way to detect if a user is mobile or desktop?
And I could have certain functions run if either is detected? Or how do you go about dealing with this?
IIRC (If I remember correctly), you can create an if
statement in case a Roblox player is in either Desktop/Mobile while getting the UserInputService
. Example:
local In_Mobile = game:GetService(āUserInputServiceā).GamepadEnabled
local In_Desktop = game:GetService(āUserInputServiceā).KeyboardEnabled
local Players = game:GetService(āPlayersā)
Players.PlayerAdded:Connect(function(player)
if In_Mobile then
print(player.Name, āis in Mobileā)
end
if In_Desktop then
print(player.Name, āis in Desktopā)
end
end)
Does the In_Mobile and In_Desktop automatically take the local player? Or how does it know which player?
It should be TouchEnabled
.
It runs in a LocalScript as UserInputService is a local service.
1 more question, is this normal for ppl who wanna make mobile/desktop game? To make different functionality for either?
Yep. Just like in any other engine. Though, some experiences, like phantom forces, have separate experiences for different devices so itās easier to manage.
Sometimes thereās API that allows you to do both and not have to detect which device the user is currently using. For example, ContextActionService
allows the developer to create a touch button which will be present if the client has touch.
Functionality should always be available for all devices unless it is truly incompatible with that device.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.