Vehicle Seat Throttle

Hello, I’m developing a car, but I need to make the buttons for the mobile devices, I’m using a normal Vehicle Seat but I don’t know how to make that when I press the GUI, (on the screen just for the phone/ipad ecc ) the Throttle changes. I’m using the RemoteEvents to trigger the event and all run well but I think that I can’t set the Throttle like this: VehicleSeat.Throttle = 1 ; so how can I make it works ?

You need to use either UIS or CAS… here is link for both:

https://developer.roblox.com/en-us/api-reference/class/UserInputService

https://developer.roblox.com/en-us/api-reference/class/ContextActionService

You don’t need to use remote events since upon sitting in the vehicle you can link the functions to this event.

Create a GUI for the player that once they are seated will connect the functions of the vehicle throttle and steering from the UI buttons to the vehicle inputs. This GUI will be accessed through UIS or CAS determining your input type.

1 Like

Do you have the GUI all set up already? Also, is your vehicle using the A-chassis or is it just a simple vehicle?

Yeah I have already set/created the GUI but is full customizable so I can add all the functions, and I based the vehicle on a normal Vehicle seat to make all simple cause I think that A-Chassis is not a good asset to use , it’s too difficult to set and there are too many things that very often a player doesn’t need to make a game on Roblox

Ok but how can I connect the functions ? cause I tried to use the Values to set the Throttle and I connected all with the Remote Functions , but how can I connect all using CAS or UIS ?

It is a bit detailed to accomplish if you still haven’t done it… DM me and i will add u to Discord to help.

Have I to add u on Roblox to write on DM ?

Detect whenever the player is sitting on the seat

--  Local script
local cas = game:GetService("ContextActionService")
local seat = path.to.seat
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
     if seat.Occupant.Parent == game.Players.LocalPlayer.Character then
           cas:BindAction("Change Seat Throttle",function()
                -- Code here
            end,true,Enum.KeyCode.T) -- Creates button for mobile and triggers whenever T key is pressed on PC
     else
           cas:UnbindAction("Change Seat Throttle")
    end
end)

I like to use

while seat.Occupant ~= nil do
--get property changed signal

The Changed function is better than a loop, since its good for performance, changed basically triggers the function whenever an instance is changed, loop on the other hand runs continuously.

And the loop you’ve mentioned will stop the code when the player sit, this means it will create the button but it will not remove whenever player leaves the seat.

1 Like

Correctomundo, I like your methodology! I’m using my application for AI players that sit! (They share)