Is there a way to stop this as ROBLOX doesn't detect it as an input released

Essentially, a user can just drag their mouse whilst holding the keycard out of the window and by doing so it wouldn’t fire an input ended (in this case, i use inputended to revert the keycard to its original position - but that isn’t happening) and then the user can drag it even lower, is there a way to stop this?

note: i can’t have a fixed position as it’s going to be the same for all doors and i’d rather have it in one script than serveral