wait(0.01)
local isOnXbox = game:GetService('GuiService').IsTenFootInterface
if isOnXbox == true then
script.Parent.Visible = false
script.Parent.Parent.XboxButtons.Visible = true
end
I currently don’t have access to my Xbox.
wait(0.01)
local isOnXbox = game:GetService('GuiService').IsTenFootInterface
if isOnXbox == true then
script.Parent.Visible = false
script.Parent.Parent.XboxButtons.Visible = true
end
I currently don’t have access to my Xbox.
IsTenFootInterface
is a method, not a property, but aside from that it’s fine. It shouldn’t need the wait.
It is considered a bool on the wiki, which is why I added in the ‘true’ statement.
I have a feeling it requires the wait function as the same code wouldn’t work previously when running.
Here is the game if you have an Xbox you can test the game on.
Start screen should say “Press A To Continue.”
Note:
It currently doesn’t support PCs with a gamepad plugged in, but I’ll be fixing that.
It returns a bool, but it’s not one. The new wiki design is a bit weird compared to the old one, but the API reference still gives you heaps of clues.
Since this is running on the client, and the information you are requesting is basically just hardware information, it should work without a wait. Not sure why it wouldn’t work previously, but if it’s a problem with code actually running then you are doing something else wrong
I’ll look into this.
Thanks!
You should check if a gamepad is connected instead of checking if they’re on console in-case someone has an xbox controller plugged into their computer
https://www.robloxdev.com/api-reference/function/UserInputService/GetGamepadConnected
https://www.robloxdev.com/api-reference/event/UserInputService/GamepadConnected
https://www.robloxdev.com/api-reference/event/UserInputService/GamepadDisconnected
I’d proceed with caution. A lot of players may have a controller plugged in (especially if it’s using a wireless adapter) and will look like they are playing exclusively on console. Always assume players are on PC when using this method
Tru tru
A better way would be to do something like
--Services
local UIS = game:GetService("UserInputService")
--Functions
function UpdateUI(LastInputType)
--Variables
local isUsingGamepad = LastInputType == Enum.UserInputType.Gamepad1
--Do whatever
end
--Events
UIS.LastInputTypeChanged:Connect(UpdateUI)
UpdateUI(UIS:GetLastInputType())
You shouldn’t be detecting if players are on an Xbox, you should be detecting if they’re using a controller. If a player has a controller plugged in but is using a mouse/keyboard, show the PC menu once they use either input device. Until then, show them the Xbox menu.
What can I do about the start screen in my game?
What about the start screen for your game? They’ll eventually move their mouse or use the gamepad, the same principle applies.
It will say “Press Any Key” for PC and “Press A to continue”
It’s the first thing that players will see when they enter my game.
Replace that with a button to play instead. Both PC players and Xbox players can click buttons.
This coupled with a BindableEvent solved my issue.
Thank you!