I am using a code that works for PC and Mobile to seperate the GUI.
It pops up the mobile GUI but not the PC
local UserInputService = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")
if UserInputService.TouchEnabled and not (UserInputService.KeyboardEnabled and UserInputService.GamepadEnabled and GuiService:IsTenFootInterface()) then
script.Parent.Loading1.Enabled = true ---If they on mobile/Pc with touch enabled
else if UserInputService.KeyboardEnabled then
script.Parent.Loading2ForPC.Enabled = true
end
end
you have an else so it can only make the gui show up for mobile use 2 if statements like this or an elseif
local UserInputService = game:GetService(āUserInputServiceā)
local GuiService = game:GetService(āGuiServiceā)
if UserInputService.TouchEnabled and not (UserInputService.KeyboardEnabled and UserInputService.GamepadEnabled and GuiService:IsTenFootInterface()) then
script.Parent.Loading1.Enabled = true āIf they on mobile/Pc with touch enabled
end
if UserInputService.KeyboardEnabled then
script.Parent.Loading2ForPC.Enabled = true
local UserInputService = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")
if UserInputService.TouchEnabled and not (UserInputService.KeyboardEnabled and UserInputService.GamepadEnabled and GuiService:IsTenFootInterface()) then
script.Parent.Loading1.Enabled = true ---If they on mobile/Pc with touch enabled
end
if UserInputService.KeyboardEnabled then
script.Parent.Loading2ForPC.Enabled = true
end
end
That last end I am getting a red siggle line under
I tested it it works for me on pc if your gui is in the right place it should work and named correctly.
local UserInputService = game:GetService(āUserInputServiceā)
local GuiService = game:GetService(āGuiServiceā)
if UserInputService.TouchEnabled and not (UserInputService.KeyboardEnabled and UserInputService.GamepadEnabled and GuiService:IsTenFootInterface()) then
script.Parent.Loading1.Enabled = true āIf they on mobile/Pc with touch enabled
end
if UserInputService.KeyboardEnabled then
script.Parent.Loading2ForPC.Enabled = true
end
I might guess it has to do with the else if? Tell me if this works:
local UserInputService = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")
if (UserInputService.TouchEnabled) then
script.Parent.Loading1.Enabled = true
elseif (UserInputService.KeyboardEnabled) then
script.Parent.Loading2ForPC.Enabled = true
end
Also just the check for TouchEnabled is enough (ļ¼¾ā½ļ¼¾)
Then, somethingās wrong with the Guiās script itās self; I doubt it has anything to do with the script to change between the mobile Gui and the PC Gui.
I am probably completely wrong and Iām miss-understanding.
Would you mind providing further details as to what the problem is?
repeat wait(1) until game:IsLoaded()
wait(5)
local UIS = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")
local divce = ''
if UIS.TouchEnabled and not UIS.KeyboardEnabled and not UIS.MouseEnabled
and not UIS.GamepadEnabled and not GuiService:IsTenFootInterface() then
divce = 'M'
end
if UIS.KeyboardEnabled and UIS.MouseEnabled and not UIS.TouchEnabled and not UIS.GamepadEnabled and not GuiService:IsTenFootInterface() then
divce = 'P'
end
if not UIS.TouchEnabled and not UIS.GamepadEnabled and GuiService:IsTenFootInterface() then
divce = 'C'
end
local player = game.Players.LocalPlayer
if divce == 'P' then -- Pc
-- Code here
end
if divce == 'M' then -- Mobile
-- Code here
end
if divce == 'C' then -- Console
-- Code here
end: