Mobile player only door

I’d like to make a door that is a mobile player only door. Does anyone know how to do this?

This is what I have so far, I don’t know what else to add to it to make it work. I’d love some help.

ismobile = game:GetService(‘UserInputService’).TouchEnabled

if ismobile == true then
–put the code you want the mobile player to run here
end

you could do this put a local script on StarterCharacterScripts then when it adds fire an event to the server with an argument of their device type then the Server can check if its Mobile or PC then write all your code between those if statements

Remember that TouchEnabled also means touch-screen laptops.
Also the GyroscopeEnabled is available on a phone.

There are no true methods to be absolutely sure about if the user is mobile.

Alternatively, check if they don’t have a keyboard.

Description:

This function returns the client’s Platform .

There is currently no supported method to detect a user’s platform. However the following API members can be used to help determine the type of device being used:

  • GuiService:IsTenFootInterface
  • UserInputService.TouchEnabled
  • UserInputService.KeyboardEnabled
  • UserInputService.AccelerometerEnabled
  • UserInputService.GyroscopeEnabled
  • UserInputService.GamepadEnabled
1 Like

ServerScriptService → Script:

local Remote = Instance.new("RemoteFunction", game.ReplicatedStorage)
Remote.Name = "PlatformRemote"


function GetPlatform(Player)
	local Data = Remote:InvokeClient(Player)
	if Data == nil then return {"error",{"error"}} end
	if #Data ~= 6 then return {"error",{"error"}} end
	local Points={pc=0, mobile=0, tablet=0, console=0}
	if Data[1] then -- Keyboard
		Points.pc += 1
	end
	if Data[2] then -- Accelerometer
		Points.mobile += 1
		Points.tablet += 1
	end
	if Data[3] then -- Gyroscope
		Points.console += 1
	end
	if Data[4] then -- Gamepad
		Points.mobile += 1
		Points.tablet += 1
	end
	if Data[5] then -- Touch
		Points.console += 1
	end
	if Data[6] then -- IsTenFootInterface
		Points.console = math.huge
	end
	local old = {"error", 0}
	local others = {}
	for i,v in pairs(Points) do
		if v > old[2] then
			old = {i, v}
		end
	end
	for i,v in pairs(Points) do
		if v == old[2] and i ~= old[1] then
			table.insert(others, i)
		end
	end
	return {old[1], others}
end


game.Players.PlayerAdded:Connect(function(Player)
	local Platform = GetPlatform(Player)
	if #Platform[2] ~= 0 then
		print(Player.Name.." is probably on: "..Platform[1].." or "..table.concat(Platform[2], " or "))
	else
		print(Player.Name.." is probably on: "..Platform[1])
	end
	--if table.find(Platform[2], "pc") or Platform[1] == "pc" then
		-- Do stuff
	--end
end)

StarterPlayerScripts → LocalScript

local Remote = game.ReplicatedStorage:WaitForChild("PlatformRemote")


local KeyboardEnabled = game:GetService("UserInputService").KeyboardEnabled
local AccelerometerEnabled = game:GetService("UserInputService").AccelerometerEnabled
local GyroscopeEnabled = game:GetService("UserInputService").GyroscopeEnabled
local GamepadEnabled = game:GetService("UserInputService").GamepadEnabled
local TouchEnabled = game:GetService("UserInputService").TouchEnabled
local IsTenFootInterface = game:GetService("GuiService"):IsTenFootInterface()


Remote.OnClientInvoke=function()
	return {
		KeyboardEnabled,
		AccelerometerEnabled,
		GyroscopeEnabled,
		GamepadEnabled,
		TouchEnabled,
		IsTenFootInterface
	}
end

That API doesn’t really work, since it’s locked to core scripts, i.e. around the engine.

I know, read the description!!

There is currently no supported method to detect a user’s platform. However the following API members can be used to help determine the type of device being used:

1 Like