Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to check what device a player is on?

Asked by 4 years ago

I made admin commands (as you can see on me Scripting Helpers profile), and for those I made a ScreenGui that has a ImageLabel . I want to be in a certain position when player joins on a certain device. I think I know the code for it, I just need to know where to get the device from

2 answers

Log in to vote
1
Answered by 4 years ago

What you will be needing is UserInputService. You can learn more about it here. Anyways here the code you will need:

local UserInputService = game:GetService("UserInputService")

if UserInputService.GamepadEnabled then
    print("Player is playing using an Xbox")
elseif UserInputService.KeyboardEnabled then
    print("Player is playing on a pc")
elseif UserInputService.TouchEnabled then
    print("Player is playing on mobile")
end

Hope it helps!

0
thanks ill try it User#29913 36 — 4y
0
thanks this really helped! User#29913 36 — 4y
0
No worries! Glad to help out :D XviperIink 428 — 4y
Ad
Log in to vote
0
Answered by
VitroxVox 884 Moderation Voter
4 years ago
Edited 4 years ago
local UserInputService = game:GetService("UserInputService")

function checkdevice()

if (UserInputService.KeyboardEnabled) then
    return "PC"

elseif (UserInputService.GamepadEnabled) then
    return "Console"


elseif (UserInputService.VREnabled) then
    return "VR"


elseif (UserInputService.TouchEnabled) then
    return "Mobile"

    end

end


print(checkdevice())

Answer this question