Remove a gui if player is on mobile

Ciao,
I have 2 gui for a mouse, since it’s custom.
There’s one problem, the mouse is seeable even if the player is on mobile.
Any way to make it possible to not make the gui enabled if on mobile?

There should be something in the UserSettings() function

1 Like

Try checking this property: UserInputService.MouseEnabled

2 Likes

One way that you can do this is check if the player is on mobile, and then set enabled to false on the gui.

For example:
create a local script and put it in startergui

local plr = game.Players.LocalPlayer
local gui = plr.PlayerGui.YourGui -- change your gui to your gui
local userInputService = game:GetService("UserInputService")

if userInputService.TouchEnabled and not (userInputService.MouseEnabled) then
     gui.Enabled = false
end
1 Like

It also applies to laptops with touchscreen which is the issue

1 Like

Oh I see, let me see what you sent and maybe edit it so its fixed.

2 Likes

Whoops, forgot the copy the not, thanks for reminding me!

2 Likes

Here is the updated script:
create a local script and put it in startergui

local plr = game.Players.LocalPlayer
local gui = plr.PlayerGui.YourGui -- change your gui to your gui
local userInputService = game:GetService("UserInputService")

if userInputService.TouchEnabled and not (userInputService.MouseEnabled) then
     gui.Enabled = false
end
2 Likes

Thank you both dudes, @VSCPlays @Slac3r
Really appreciated the help.

2 Likes

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