Detecting when player leaves proximity for ProximityPrompts

Hi everyone, I’m tinkering around with ProximityPrompts for my shop, and I want the ShopGui to close when the player walks away from the NPC. However, I didn’t find any event that fires when the player leaves the “proximity”. Is there any way to do this?

I’m hiding the ProximityPrompt(Enabled = false) when the ShopGui is open, so using PromptHidden doesn’t work.

Edit: Constantly checking the magnitude of the character and the NPC’s torso is one solution, but I think that could cause a lot of lag.

ProximityPrompt | Documentation - Roblox Creator Hub / ProximityPrompt | Documentation - Roblox Creator Hub

Yea I tried that, but it fires when I set the proximity prompt.enabled to false

I want the shop to close when the player walks away, not when the ProximityPrompt.Enabled is set to false.

If you could implement sanity checks, like if the game knows the player is on Island 1 because they fired a remoteevent to enter that Island, it wouldn’t check for magnitude fo things that are obviously far away.

Also I don’t think it would cause a lot of lag anyways. Magnitude is a property if I recall correctly, not a yielding or expensive function.

Ok, I’ll definitely try it out. Thanks!