Detect movement when touching part

So basically, I want a function to fire when you are touching a certain part and move.

I tried UserInputService inside part.Touched but it didn’t work well.

here is my script:

 local part = script.Parent 
    part.Touched:Connect(function(hit)
    local UIS = game:GetService("UserInputService")
    if   UIS.InputBegan:Connect(function(input, GPE)  
               print("you moved while touching that part" )
         end)
end)

Have you tried using MoveDirection?

Check this thread:

Detect Player Movement

1 Like