Basically run a function that fires when the raycast result changes. If the result Part.Name is a mine and you walk onto it you then you can use an if statement to see if is changing from that Part to any other part or Terrain. Then Kaboom!!
Seems like you just need to increase the length of the raycast. If you have it 0.1 studs tall, it’ll probably deactivate immediately after activating because of walking animations moving legs away from the mine, causing the raycast to not detect anything. With a longer raycast (say, 5 studs), the entire character will be detectable by the mine, which will reduce the chances of detected body parts falsely moving away from the raycast due to animations.
You would need an active state for your land mines. User your RaycastResult to determine what instance is currently beneath your feat (Raycastresult.Instance) and if that instance is one of your land mines then set the land mines active state to true, once that same land mine is no longer detected, set the active state to false.
Use a :Changed() function to detect a change in this state, within that function check if this state has been changed to false, if it does, explode. (This will not trigger if the initial state is false).
Wouldn’t just checking for if the Changed state goes from Top (the mine’s name) to anything else work more easily?
Function Raycastresult Part.Name state Changed
if the name state changes to Top then
repeat until name state Changed()
task.wait(.2 or however long you want to wait after the player leaves the mine)
But Raycastresult returns the actual Part, right?
If you check if Raycastresult Part.Name changed to Top that sets the repeat until loop starting, which will then repeat until the Raycastresult’s Part.Name changes to anything else, then it’ll explode.