How do I fix the flatform/device tag e.g. Check if the user is in mobile/pc/console

IDK how do I fix this script it doesn’t work

image
Even I’m in mobile it showing this

Script

RemoteEvent.OnServerEvent:Connect(function(player, device)
    if device == "Console" then
      GuiClone.Frame.IconHolder.Console.Visible = true
    elseif device == "Computer" then
      GuiClone.Frame.IconHolder.Computer.Visible = true
    elseif device == "Mobile" then
      GuiClone.Frame.IconHolder.Mobile.Visible = true
    end
end)

Local Script

local UserInputService = game:GetService("UserInputService")
local deviceCheck = game.ReplicatedStorage:FindFirstChild("deviceCheck")

if UserInputService.GamepadEnabled and not UserInputService.KeyboardEnabled and not UserInputService.MouseEnabled then
	deviceCheck:FireServer("Console")
elseif UserInputService.KeyboardEnabled and UserInputService.MouseEnabled then
  deviceCheck:FireServer("Computer")
elseif UserInputService.TouchEnabled then
  deviceCheck:FireServer("Mobile")
end

Why did you put Computer instead of Mobile, if the frames inside IconHolder have the exact name as the devices?

Oops, I already tried it but doesn’t work even in my controller
image
image

For the LocalScript, try to remove all the and not conditions for the console. I’m not sure if it will work or not, since I didn’t want to test and see if it will work or not. If it didn’t work, reply to me, okay?

Sure let me try to remove that.

I didn’t know why its not working but I already check the all variables and if the deviceCheck event was there.

Actually nevermind. I just check the pictures again and it didn’t seems to make any sense for me.

Maybe try this one? I’m not sure if it will solve the problem, but it’ll worth a shot. (in the main script)

RemoteEvent.OnServerEvent:Connect(function(player, device)
    if device == "Console" then
      GuiClone.Frame.IconHolder.Console.Visible = true
      GuiClone.Frame.IconHolder.Computer.Visible = false
      GuiClone.Frame.IconHolder.Mobile.Visible = false
    elseif device == "Computer" then
      GuiClone.Frame.IconHolder.Console.Visible = false
      GuiClone.Frame.IconHolder.Computer.Visible = true
      GuiClone.Frame.IconHolder.Mobile.Visible = false
    elseif device == "Mobile" then
      GuiClone.Frame.IconHolder.Console.Visible = false
      GuiClone.Frame.IconHolder.Computer.Visible = false
      GuiClone.Frame.IconHolder.Mobile.Visible = true
    end
end)

Looking at your code, youre missing a parameter that you added for the event, which is player. Maybe try to inlcude the LocalPlayer when attempting to fire server.

I also suggest using print("Code Passed Up To Here") in some places where functions run to make sure it fired and ran properly, then you would know it would most likely be another problem.

So how do I add the player parameter?

I already did that for debugging.

Well, first you gotta figure out why you added that as a parameter in the first place.
I was guessing you added that there so it can find the player UIInput Type, and to find the character of the player. You can find how to get the local player in the Developer Hub.

Btw, when you were debugging with print, was everything working properly?
And, when you run the game, does it randomly pick from the ui images, or specifically 1 every time on one device?

But in roblox studio it’s working but in the roblox doesn’t work

Sorry can you clarify what’s working?

And make sure your place is published to roblox in order for changes to save.

If I’m in studio its working but in normal server not in roblox studio its not working

Oh, without you making any changes to the script?

If you made any changes to your place in studio, make sure you publish to roblox so it can update the servers to work.

I did and can you help me to fix it?

So it’s still not working even if you recently published to roblox?

Yeah I already publish it but its not working

How do I check if the player is in console or mobile?

if table.find(Platform[2], "mobile") or Platform[1] == "mobile" then
	 --Do stuff
end
if table.find(Platform[2], "console") or Platform[1] == "console" then
	 --Do stuff
end