Correct Syntax for ContextActionService?
I only slightly know what I'm doing with this, the Roblox Wiki didn't explain much. So, I'm trying to have a detection for when the mouse is moved, Left Mouse button is down, The Player Name matched a value, AND the part they are touching matches a specified name. I've experimented with different methods & events but they all proved too laggy or impractical.
Back to the point though, anyone with knowledge regarding ContextActionService care to help me out? Something isn't working here, but I don't know what it is. I have narrowed down the location of the error/broken code to either Lines 6, 7, or 17.
01 | local Player = game.Players.LocalPlayer |
02 | local Mouse = Player:GetMouse() |
03 | local Leader = workspace.Leader.Value |
05 | Mouse.Move:connect( function () |
06 | function Detonate(actionName, userInputState, inputObject) |
07 | if userInputState = = Enum.UserInputState.Begin then |
08 | print ( "Input State Works!" ) |
09 | local Target = Mouse.Target |
11 | if Player.Name = = Leader and Target.Name = = "button" then |
17 | game.ContextActionService:BindAction( "Detonate" , Detonate, false , Enum.UserInputType.MouseButton 1 ) |
Line 12 does reference a function located elsewhere in the script, but I left it out since it doesn't share any variables/objects/etc with the code I have listed above. Any help is appreciated. Thanks! :)
EDIT: I am fairly certain is has something do with the way I laid out the syntax, hence the title. But as I said before I don't have any experience using ContextActionService so I'm not entirely sure. Just wanted to clarify.
EDIT 2: Just realized its ContextActionService, not BindAction. I think. Changed everything, but my question still stands.