Well I trying to figure it how... I'm really stuck my game need a special mobile button to do something pls help me!
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 )