So obviously, there is a lot of differences of console games versus Computer/Mobile. The biggest one is being unable to click on things on the screen…
So, what are some various things that I’d need to know in order to get started?
Also, what do I need to do to recognize Xbox Inputs?
Like, I have this script to utilize the “M” button on a Keyboard to open up a menu:
key = string.lower(key)
if string.byte(key) == 109 then
loca= game.Players.LocalPlayer.PlayerGui.CustomizeGUI.Frame
loca2= game.Players.LocalPlayer.PlayerGui.RaceResults.Frame
if loca.Visible == false and loca2.Visible == true and game.Players.LocalPlayer.PlayerGui.CustomizeGUI.Frame.Control.ISOK.Value == true then
loca.Visible = true
else
loca.Visible = false
end
running = true
local keyConnection = mouse.KeyUp:connect(function (key)
if string.byte(key) == 109 then
running = false
end
end)
end
end)
Would I just change the 109 byte key (which is M on keyboard) to 1000 for the X Button on a controller, or do I only do that for a person trying to use a Controller on PC, or does it work for both, or…?
Also, does a generic Roblox VehicleSeat allow for controlling of a car with a controller? Is that by default set up in a certain way, or do I have to go about making them for myself?
Also the old Xbox Featuring Checklist, is that only to get featured? Or is that simply to have a game on Xbox?
Added Question:
Can you test a “Console” game on a PC with a Xbox Controller connected to the PC?
There are currently no requirements to have a game on Xbox, all you have to do is enable it for console on the the configure page.
As for detecting input in general, you should be using InputBegan and InputEnded instead. Also, the :connect method is deprecated in favor of using :Connect.
You can use UserInputService and ContextActionService to more easily bind many of the same actions to XBox as you would for PC. UIS and CAS are more favorable, flexible, and have more features than the deprecated KeyDown method. Here are some resources if you’re interested:
I have a couple (hopefully) useful YouTube tutorials that can help you get started, if you’re into that sort of thing. UserInputService ContextActionService
Here’s an example of how you could perform the action of opening a menu on both controller and keyboard with UIS.
local UIS = game:GetService("UserInputService")
UIS.InputBegan:connect(function(inputObject, gameProcessedEvent)
if gameProcessedEvent then return end --// don't want to do anything if they're typing "m" into roblox chat for instance
if inputObject.KeyCode == Enum.KeyCode.M or inputObject.KeyCode == Enum.KeyCode.ButtonA then --// check if they pressed key "m" or button "a" on their gamepad
menu.Visible = not menu.Visible --// you get the gist
end
end)
Plenty of info on the wiki about recommendations for gamepad input too. And finally, I found the page for the InputObject object to be pretty valuable when I was starting out.
The vehicle seat does work with a controller, but it’s pretty awful as the left thumb stick is used for acceleration and braking as well as steering, with the triggers doing nothing.
The featuring checklist is only to get featured, however I would still recommend following those guidelines as they are some pretty good tips and you’d need to follow it if you ever wanted to become featured.
Would it be possible to use a regular vehicle seat with a controller with proper “car” settings? (Triggers for gas/brake, and thumb stick for steering?)
It is completely possible. I did so myself on a game that was abandoned a few months ago. A stick on a controller has a plane with an x-axis and a y-axis, with left being negative and right being positive on the x, and down being negative and up being positive on the y. The most a stick can go ranges from -1 to 1 (on both axis). To find this input, you can use this function:
game:GetService(“UserInputService”).InputChanged:connect(funtion(key)
if key.KeyCode == Enum.KeyCode.Thumbstick2 then
print(key.Position.X … ", " … key.Position.Y)
end
end
Sorry about messiness, I’m currently typing this on a phone at school.
You don’t need a seat, the seat is irrelevant. You put the code above in a local script, and the code gives you values for throttle and steer, and then you do what you like with them.
Give me a minute to get my laptop and I’ll update it to be clearer for what you want to do.
I’m going to guess I’m wrong here, but I’ll give it a shot. I have a menu gui for the intial landing place. If I wanted a player to press Start on the Xbox Controller to go to the Competitive Game Mode, would this code be right? Also, where would I put this code? (Mind you, I want this to work for a player using a Xbox Controller on a Xbox, without any care for a PC user using a Xbox controller.)
s = game:service("TeleportService")
id = 279768772
game:GetService("UserInputService").InputBegan:connect(function(input)
if input.UserInputType == Enum.UserInputType.Gamepad1 then
if input.KeyCode == Enum.KeyCode.ButtonStart then
s:Teleport(id)
end
end
end)
Ah sorry, thought you were just using the Vehicle Seat to read the Throttle and Steer values, but I take it you’re actually using it to make cars move without needing any code?
I am. Just basic Tank Chassis garbo. I’d make more complex versions of the cars, but I don’t have a lot of experience with scripting cars, and there isn’t a whole lot of guides for it.