How to script cars to work for PC and Mobile?

Hi Developers,

So, I was wondering, How do I make a car work for PC AND mobile? Like GreenVille, if you check their car driving style i’m kind of aiming for that. But they have a script that for PC it shows no GUI’S in the car because they can just click WASD to move. While the Mobile Players need a GUI because it wont operate for them since they don’t have WASD, any idea on how to script this?

1 Like

Cars on mobile work with just using the thumb stick. You could make a custom gui if you want but you don’t have to

The ones i’m using don’t, anyway to fix?

How would I script the gui to make the car move?

by default vehicle seats work with mobile

It’s not going…

1 Like

I’m rlly sorry. I’m not too skilled with this stuff. I’m not sure why it’s not working but I know the default way to make vehicles does work with mobile

Oh, it’s alright. Thanks for the help though.

1 Like

I think you could use contextbindservice, More specifically the “ContextBindAction” function, It allows you to bind both pc and mobile controls to an action such as driving.

Roblox shows the following code:

local ContextActionService = game:GetService("ContextActionService")
 
local ACTION_RELOAD = "Reload"
 
local tool = script.Parent
 
local function handleAction(actionName, inputState, inputObject)
	if actionName == ACTION_RELOAD and inputState == Enum.UserInputState.Begin then
		print("Reloading!")
	end
end
 
tool.Equipped:Connect(function ()
	ContextActionService:BindAction(ACTION_RELOAD, handleAction, true, Enum.KeyCode.R)
end)
 
tool.Unequipped:Connect(function ()
	ContextActionService:UnbindAction(ACTION_RELOAD)
end)

Search mobile support achassis!