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

Context Action Service How to make it work on filtering enabled?

Asked by 5 years ago

Well I trying to figure it how... I'm really stuck my game need a special mobile button to do something pls help me!

1 answer

Log in to vote
0
Answered by 5 years ago

The ContextAction:BindAction( string actionName, Function functionToBind, bool createTouchButton, Tuppe inputTypes ) method can only be called from a LocalScript, so your function bound needs to have a FireServer() or InvokeServer() depending if it is a RemoteEvent or RemoteFunction.

Take this code for example:

Server Script:

game.Workspace.RemoteEvent.OnServerEvent:Connect(function(plr)
    game.Workspace.Baseplate.BrickColor = BrickColor.Random()
end)

LocalScript:

function changeColor()
    game.Workspace.RemoteEvent:FireServer()
end

game:GetService("ContextActionService"):BindAction(
    "ChangeColour",
    changeColor,
    true,
    Enum.KeyCode.C
)
Ad

Answer this question