Normally I would use GamepadEnabled
do detect if a user is on console. I recently saw somewhere that this shouldn’t be used, as players can obviously have controllers with PC (like myself) but some people leave their controllers plugged into their PC’s. Instead using GetLastInputType
to determine whether the user is actually using their gamepad, or if it is just plugged in and the user intends to use keyboard and mouse.
So the question is, is it worth using GetLastInputType over GamepadEnabled or is it very rare that users would have a controller plugged in and not use it?
Using something like this:
renderStepped = runService.RenderStepped:Connect(function()
local playerGui = player.PlayerGui
if not playerGui then return end
local insideDistance = (insideDoor.Teleport.CFrame.p - character.HumanoidRootPart.CFrame.p).magnitude
local outsideDistance = (outsideDoor.Teleport.CFrame.p - character.HumanoidRootPart.CFrame.p).magnitude
local lastInput = userInputService:GetLastInputType()
if insideDistance <= settings.Distance or outsideDistance <= settings.Distance then
local enterClone = playerGui:FindFirstChild('Enter')
if enterClone then return end
local enterClone = enter:Clone()
if not enterClone then return end
print(lastInput)
if lastInput == Enum.UserInputType.Gamepad1 then
enter.ControlPC.Visible = false
else
enter.ControlPC.Visible = true
end
enterClone.Parent = playerGui
else
local enterClone = playerGui:FindFirstChild('Enter')
if not enterClone then return end
enterClone:Destroy()
end
end)
For some reason, when the UI first shows up, the PC icon is invisible, then every other time after that it is visible.