Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Mobile Attack Button not working?

Asked by 4 years ago

I'm very new to scripting and have completed most of my new game. However, I seem to be stuck on something that other people may consider simple.

I'm attempting to make button for Mobile Devices that simulates the same thing that happens when a user left clicks there mouse to complete an attack move with the Tool they have equipped.

I have gotten the Mobile Button to show up, but no matter what kind of code i try i cant seem to actually get the attack move to excute.

I'm not looking for a handout, just a step in the right direction.

Thank you for your time!

Here is the code i have so far:

local ContextActionService = game:GetService("ContextActionService")

local function Attack()


end

local function ProcessAction(ActionName,InputState,InputObject)
    -- This function ProcessAction will be called both when the key is pressed, and
    -- when it is released.
    -- We want to make sure this only proceeds if the key is pressed, and not released.
    if InputState == Enum.UserInputState.Begin then
        -- If the ActionName is correct, proceed and call the Attack function.
        if ActionName == "Attack" then
            Attack()
        end
    end
end

-- The third parameter specifies whether there will be an on screen button for Mobile.
-- And all the parameters after that are the additional sources of input.
ContextActionService:BindAction("Attack", ProcessAction, true, Enum.KeyCode.Space, Enum.KeyCode.ButtonR2)

ContextActionService:SetPosition("Attack",UDim2.new(0,0,0,0))
ContextActionService:SetTitle("Attack","Attack")

Answer this question