AI Still Sees The Player When Layer Has Changed

I have a respawn setup that moves the player to the spawn position and changes the layer of the object as to be invisible to the AI (using layermasking). When the player presses ‘F’ the layer changes back so that the AI can see them again, but changing the layer does not make the player invisible to the AI. How can I fix this?

ps. Everything works fine, the layer does in fact change, but the AI does not realise the change in layers.

Shit I made the stupidest mistake. sorry! I didn’t have a collider on the object that the AI uses to see the player.