Hello. I am currently struggling with finding a way to display someone’s device server side. How would I go about doing so? (I am looking for it to show up on a overhead tag)
Hi! You could use the UserInputService and check if:
game:GetService(“UserInputService”).TouchEnabled - mobile
game:GetService(“UserInputService”).KeyboardEnabled - PC
game:GetService(“UserInputService”).GamepadEnabled - Console
https://developer.roblox.com/en-us/api-reference/property/UserInputService/TouchEnabled
https://developer.roblox.com/en-us/api-reference/property/UserInputService/KeyboardEnabled
https://developer.roblox.com/en-us/api-reference/property/UserInputService/GamepadEnabled
Yes, but how would I go about having it show server side?
Use a RemoteEvent to communicate with the server and UserInputService and GuiService to detect the player device.
LocalScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local GuiService = game:GetService("GuiService")
local CurrentCamera = workspace.CurrentCamera
local RemoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local function getPlatform()
if GuiService:IsTenFootInterface() then
return "Console"
elseif UserInputService.TouchEnabled and not UserInputService.MouseEnabled and not UserInputService.KeyboardEnabled then
if CurrentCamera.ViewportSize.Y > 600 then
return "Tablet"
else
return "Mobile"
end
else
return "Computer"
end
end
RemoteEvent:FireServer(getPlatform())
Server script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage.RemoteEvent
local Devices = {"Computer", "Mobile", "Tablet", "Console"}
RemoteEvent.OnServerEvent:Connect(function(player, Device)
if table.find(Devices, Device) then
print(Device)
end
end)
Those properties can only be fetched from the client so you’ll need to transfer them to the server via a RemoteEvent/RemoteFunction instance.
Ohhhhh yea, I am sorry
Thank you very much! This is very useful