I’m making a door script but when testing in tablet and phone mode it spits out attempt to compare Vector2 < Vector2 for no reason!
--Client-side version for the DoorModule
local GuiService = game:GetService("GuiService")
local UserInputService = game:GetService("UserInputService")
local ContextActionService = game:GetService("ContextActionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Camera = workspace.CurrentCamera
--Device checkers
local function CheckIfGamepad()
--GuiService.SelectedObject is used for gamepads and xbox does so.
if GuiService.SelectedObject ~= nil then
return true
end
return false
end
local function CheckIfXbox()
local IsGamepad = CheckIfGamepad()
if IsGamepad then
if Camera.ViewportSize == Vector2.new(1920, 1080) or Camera.ViewportSize < Vector2.new(1920, 1080) then
return true
end
end
return false
end
local function CheckIfPhone()
local TouchEnabled = UserInputService.TouchEnabled
if TouchEnabled then
if Camera.ViewportSize == Vector2.new(852, 414) or Camera.ViewportSize < Vector2.new(852, 414) then
return true
end
end
return false
end
local function CheckIfTablet()
local TouchEnabled = UserInputService.TouchEnabled
if TouchEnabled then
if Camera.ViewportSize == Vector2.new(1280, 800) or Camera.ViewportSize < Vector2.new(1280, 800) then
return true
end
end
return false
end
local t = {}
t.SetupDoor = function(Door, KeyBindFunc)
--Sets up the door keybinding functions and UI.
local IsXbox = CheckIfXbox()
local IsPhone = CheckIfPhone()
local IsTablet = CheckIfTablet()
local UiKey = Door.UiKey
local UiXboxKey = Door.UiXboxKey
if IsXbox then
--Xbox
UiKey.Enabled = false
UiXboxKey.Enabled = true
ContextActionService:BindAction("DoorKeybind", KeyBindFunc, false, Enum.KeyCode.ButtonA)
elseif IsPhone then
--Phone
UiKey.Enabled = true
UiXboxKey.Enabled = false
UiKey.Key.Visible = false
ContextActionService:BindAction("DoorKeybind", KeyBindFunc, true)
elseif IsTablet then
--Tablet
UiKey.Enabled = true
UiXboxKey.Enabled = false
UiKey.Key.Visible = false
UiKey.Tap.Position = UDim2.new(0.05, 0, 0.05, 0)
UiKey.Tap.Size = UDim2.new(0.9, 0, 0.9, 0)
ContextActionService:BindAction("DoorKeybind", KeyBindFunc, true)
else
--PC
UiKey.Enabled = true
UiXboxKey.Enabled = false
UiKey.Tap.Visible = false
ContextActionService:BindAction("DoorKeybind", KeyBindFunc, false, Enum.KeyCode.E)
end
end
t.CreateClientDoor = function(Door)
--This is important for the door to work
t.SetupDoor(Door, function()
--Disables the door
print(true)
--ReplicatedStorage.OpenDoor:FireServer(Door.Name)
end)
end
return t