Hey everyone! I’m trying to make my game compatible with more devices, however I cant figure out how to make it on tablet. I got it right on Computer and phone, but not on laptop.
I think I need an new one for Phone too, as it is returning that I’m using an phone instead of Laptop.
I tried to search the forum, but I could’nt find anything
You can only say if person is on touch device, not if its 100% mobile/tablet.
local UIS = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")
if UIS.TouchEnabled and not UIS.KeyboardEnabled and not UIS.MouseEnabled
and not UIS.GamepadEnabled and not GuiService:IsTenFootInterface() then
-- mobile device
end
Also here is what I googled: “check if plr is on touchdevice roblox”
Not only is that locked behind RobloxScriptSecurity, there are about five different mistakes in that script.
Tablet is the member of the DeviceType Enum, not its own Enum. You’d have to specify Enum.DeviceType.Tablet, or check if what GetDeviceType returns has a Name of “Tablet”.
Methods can be referenced with . and called with either . or :. You can’t reference a method with : without calling it. Specifically, x:y() is shorthand for x.y(x), so it wouldn’t make sense to store that the first parameter when called is going to be x, meaning you can’t store x:y on its own.
Here you’re assigning a value to GetDeviceType, which probably isn’t what you meant to do. If you’re checking equality, it’d be ==, but you can’t just replace that = with a == and call it a day. You need an if statement or somewhere to store the boolean.