#How could I add a right click or left click to my game on controller?

1 messages · Page 1 of 1 (latest)

agile flame
#

sometimes my left click acts like a trigger but still unable to find an alternative for a right click on controller

sour canyon
#

@agile flame context action service

agile flame
sour canyon
#

yea wait so you want an alternative to pc "leftclick/rightclick" to a console controller right?

#

@agile flame

agile flame
#

like for example i have a tool in my hotbar which i have to left click first (which works) but to activate it i need to right click after warss

sour canyon
agile flame
#

i managed to find a script with userinputservice but nothings really woring

#

i tried controller emulator too

sour canyon
#

context action service lets you bind actions to keys and buttons

agile flame
#

my keybind “F” is the 2nd trigger to the tool i am using and i tried putting L2 as my “F” but nothings happened

sour canyon
#

"Context Action Service in Roblox is a useful tool for cross-platform support. It can bind one function to multiple key binds from different platforms."

sour canyon
#

its like alternative to UIS

agile flame
agile flame
sour canyon
#

yea i just learned it yesterday

#

um

#

if you want crossplatform stuff

agile flame
#

if so how could I do it yeah

sour canyon
#

yknow how mobile games have those buttons?

agile flame
#

yes

sour canyon
#

yea its by context action service

#

so basically you just make a function

#

for example attack function

#

and you use BindAction to make like for example Keycode.LeftClick, Mobilebutton, or even controller buttons

#

so those 3 inputs do the same "Attack" action

#

you call this "BindAction(actionName: string,functionToBind: function,createTouchButton: boolean,inputTypes: Tuple):()"

#

(it automatically creates a mobile button for you)

#

not sure how to do it with controller yet, but i know it can

agile flame
#

holy okayyy

#

it may js be the system im using doesnt supoortt the keybinds of a controller

#

but certain thatd not the problem

#

thats

sour canyon
#

-- 1. The Function that runs when the button is pressed
local function onAttack(actionName, inputState, inputObject)
    if inputState == Enum.UserInputState.Begin then
        print("Flash Punch triggered via: " .. inputObject.KeyCode.Name)
        -- Call your attack function here!
    end
end

-- 2. Bind the action
-- Arguments: ("Name", function, createMobileButton, Key1, Key2, Key3)
CAS:BindAction("SpeedPunch", onAttack, true, Enum.KeyCode.F, Enum.KeyCode.ButtonX) ```