Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to change pc buttons to android?

The game is PC and Android, but on Android does not have equal PC buttons. So how to dumb to Android? (I'll separate a script for each platform.)

Mouse.KeyUp:Connect(function(key) 
if key:lower() == "w" then 
ctrl.f = 0 
elseif key:lower() == "s" then 
ctrl.b = 0 
elseif key:lower() == "a" then 
ctrl.l = 0 
elseif key:lower() == "d" then 
ctrl.r = 0 
end 
end)

-- Doubt...

For me, I do not need to open another Post now, how do I disable the other buttons and activate? For me to put while I'm flying the other keys do not work and when I'm not flying the keys stay active again?

1 answer

###You should not using KeyDown or KeyUp. They are deprecated and should not be used in new work. Apart from that it's just an inconsistent way to get user input.

###Use UserInputService or ContextActionService to get user input and to make mobile compatible games.

local ContextActionService = game:GetService("ContextActionService")

local function doStuff()
    -- code
end

ContextActionService:BindAction(
    "DoStuff", -- name of action
    doStuff, -- function to bind
    true, -- create mobile button
    Enum.KeyCode.W -- keys to bind
)

1 comment

0

Okay, this is not my real script, it's a random one I found. In my I use UserInput. I'll test Context if I can or not, I come here, see you later.

This discussion is preserved as it was. New answers, comments, and votes are closed.