OOP Binding Actions

I was recently trying out OOP and im still no where close to knowing it but I have a simple grasp of it.
But… why isn’t this working?

local ghostTable = placementModule.createGhost()

------This Part Under Doesn't Work------
game.ContextActionService:BindAction("RotateGhost",ghostTable:UpdateRotation(45),false,Enum.KeyCode.R)

Error:

Argument 2 missing or nil

try this,

game.ContextActionService:BindAction("RotateGhost", ghostTable.UpdateRotation(45), true, Enum.KeyCode.R)

Still the same. I’ve changed both of the connections.

The second argument is a function, and by doing function(45) you are calling it and putting whatever is returned there instead, you need to put only function (without the ())

game.ContextActionService:BindAction("RotateGhost",function()
ghostTable:UpdateRotation(45)
end ,false,Enum.KeyCode.R)

wrote this on mobile!

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.