Help with context action service

Hello fellow developers ! I have prepared a sword for my game which can also block incoming attacks while the sword is equipped and the player has to right click to block. Now for the mobile players I will have to create a context action service command but I am struggling on linking the context action service button to the right click. I will really appreciate nay help I receive on this.

3 Likes

it would be nice if you provided some code so we could help you

1 Like

oh yes , sorry I forgot to the provide the code.

local ContextActionService = game:GetService("ContextActionService")
local tool = script.Parent
if tool.Equipped == true then
	tool.Equipped:Connect(function ()
		ContextActionService:BindAction()
	end)
end

I don’t know what action to bind for right click.

try using Enum.UserInputType.MouseButton2

so

Cas:BindAction("YourFunctionName",Function(),true,Enum.UserInputType.MouseButton2)
5 Likes

I made the script but the button is not appearing on the screen. I have made the script as a local script inside the tool. Do I have to create the script inside a starter gui?

you should make the bool value as true to make it appear

1 Like