Won't work on pc

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

3 Likes

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

end

This has lots of errors in it.

You just telling me to remove the else?

yes and put an end between the 2 ifs at the end of the first if statement and the last

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

remove one of the ends at the last block you only need one not two

STill does not work for pc.

Its really werid

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

1 Like

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 (ļ¼¾ā–½ļ¼¾)

2 Likes

I was having that issue to it was not destroying but I put the code another place and wear it was still click able

Are you just trying to re-size the GUI?

um no.

I am trying to make it so if someone is on mobile they get different gui than someone on pc

How To Show A GUI Only On Mobile (Roblox Studio) - YouTube

Thats not the problem the GUI is semi-working.

It looks like the code works in the GUI but not the GUI

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?

I have made one of them before, here is the code

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:

Where did you put the script in?