Another alternative is to use ZonePlus .It’s useful module to detect if a player entered a part or left a part.
Have a look:
After grabbing the module put it in ReplicatedStorage and name it “Zone” and drop this code into your script.
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local SafeZone = -- PATH TO YOUR SAFEZONE PART
local zone = Zone.new(container)
zone.playerEntered:Connect(function(player)
-- Let the player be safe, he entered the safe zone.
end)
zone.playerExited:Connect(function(player)
-- Let the Player not be safe anymore, he left the safe zone.
end)