UI Separation script for PC and Mobile Needed

Why should it go in collaboration?

I asked if it was possible to do that.

I literally said that and said I tried almost all the scripts.

Ok now I got this

local UserInputService = game:GetService("UserInputService")

function ReturnDevice()
	if UserInputService.KeyboardEnabled then
		script.Parent.Loading1_PC.Enabled = true
	elseif UserInputService.GamepadEnabled then
		print("No")
	elseif UserInputService.KeyboardEnabled and UserInputService.TouchEnabled then
		script.Parent.Loading1_PC.Enabled = true
	elseif UserInputService.TouchEnabled then
		script.Parent.Loading1.Enabled = true
	else
		return false
	end
end

I think you cant do game.StaterGUI. (Because I tried that already)

Someone told me you have to do like PlayerGUI or something but I cant find that and dont know how to do that.

(Its in StaterPlayer - StartingPlayerScripts as a Local Script)

Depending on your situation using the player’s input type isn’t beneficial. You can basically tell if someone is on a laptop or tablet/phone based off their ViewportSize in pixels. If Roblox’s API descriptions hold up GuiService | Roblox Creator Documentation can be used to identify console players.

I would less worry about the exact device a player is using a more focus on the characteristics of their device because over the past few years devices have been starting to cross boundaries as technology improves.

1 Like

I am not really conserd about console

Just more about PC and Mobile.

But thank You

How would I get the characteristics of a Mobile or PC device?

Update:

tried this it didn’t work

local UserInputService = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer 

function ReturnDevice()
	if UserInputService.KeyboardEnabled then
		plr.PlayerGui:WaitForChild("Loading1_PC").Enabled = true 
	elseif UserInputService.KeyboardEnabled and UserInputService.TouchEnabled then
		plr.PlayerGui:WaitForChild("Loading1_PC").Enabled = true 
	elseif UserInputService.TouchEnabled then
		plr.PlayerGui:WaitForChild("Loading1").Enabled = true 
	else
		return false
	end
end

You should check Cross-Platform Design | Roblox Creator Documentation out, it might help you, you can also try using this function to detect the last input type the player used: UserInputService | Roblox Creator Documentation

This is a basic function right here that does the job

local UserInputService = game:GetService("UserInputService")

local Mobile = false


coroutine.wrap(function()
	while wait(1) do
		Mobile = (UserInputService.TouchEnabled and not UserInputService.KeyboardEnabled)
	end
end)();


-- The "UI" variable below just acts as if I have a ScreenGui and a PC / Mobile frame inside of it.
local UI = Mobile and Gui.Mobile or Gui.PC

Then after this you could create a BindableEvent that fires whenever mobile changes. After that you could connect a Update Interface function that changes to pc if mobile is false , and vice versa.

Hmm ok.
Where would you put this?
Btw I made 2 seperate ScreenGuis - 1 for mobile 1 for pc

Btw I edited the post so you all can see my current problems

What do you mean by

So the loading screen does not show but the LoadingScreen scripts work and both UI’s appear.

?

Its a loading screen

So if there on mobile the loading screen is enabled and everything else is invisible but after some time both the invisble stuff become visible.

Its like the UI wont show but the script is still working.

Well assuming that it’s just a loading screen when a player enters the game you’d throw this in a LocalScript inside of the ScreenGui and you would parent the ScreenGui to ReplicatedFirst

Also, for two seperate ScreenGuis you could just do something like this

local ui = Mobile and game.ReplicatedFirst:WaitForChild("MobileGui") or game.ReplicatedFirst:WaitForChild("PCGui")
ui:Clone().Parent = game:GetService("Players").LocalPlayer:WaitForChild("PlayerGui")

The screenGUI’s are seperate with different postions and size and stuff but thank you

I think you don’t understand what I am saying. Position and Size are UDim2 properties which have nothing to do with UserInputService for detecting if a device is mobile and cloning the UI and putting it into PlayerGui.

Feel free to upload a place file with your two ScreenGuis and I would gladly give you a solution for this.

Yeah I know.

I am saying theres 2 screen GUI’s.

The same GUI but with different size and postion.

It didn’t work anyways.

It 100% works I literally use it in my own projects. Show me an example of how you’re using it.