local Workspace = game:GetService("Workspace") local StarterGui = game:GetService("StarterGui") local humFolder = Workspace:WaitForChild("Hum") local notifiedAnomalies = {} local connections = {} local function isAnomalyModel(model) if not model:IsA("Model") then return false end local anomalyValue = model:FindFirstChild("Anomaly") return anomalyValue and anomalyValue:IsA("BoolValue") and anomalyValue.Value end local function sendAnomalyNotification(anomalyModel) if notifiedAnomalies[anomalyModel] then return end notifiedAnomalies[anomalyModel] = true -- Use pcall to prevent errors if SetCore isn't ready local success, err = pcall(function() StarterGui:SetCore("SendNotification", { Title = "⚠️ Anomaly Detected!", Text = "Anomaly (" .. anomalyModel.Name .. ") has appeared!", Icon = "rbxassetid://6031071053", -- Warning icon Duration = 5, }) end) if not success then warn("Failed to send notification:", err) end end local function monitorBoolValue(model, anomalyValue) if connections[anomalyValue] then return end connections[anomalyValue] = anomalyValue.Changed:Connect(function(newValue) if newValue then sendAnomalyNotification(model) else -- Reset notification when anomaly is deactivated notifiedAnomalies[model] = nil end end) if anomalyValue.Value then sendAnomalyNotification(model) end end local function setupModelMonitoring(model) if not model:IsA("Model") then return end local anomalyValue = model:FindFirstChild("Anomaly") if anomalyValue and anomalyValue:IsA("BoolValue") then monitorBoolValue(model, anomalyValue) end if not connections[model] then connections[model] = model.ChildAdded:Connect(function(child) if child.Name == "Anomaly" and child:IsA("BoolValue") then monitorBoolValue(model, child) end end) end end local function cleanupModel(model) notifiedAnomalies[model] = nil if connections[model] then connections[model]:Disconnect() connections[model] = nil end local anomalyValue = model:FindFirstChild("Anomaly") if anomalyValue and connections[anomalyValue] then connections[anomalyValue]:Disconnect() connections[anomalyValue] = nil end end for _, child in ipairs(humFolder:GetChildren()) do setupModelMonitoring(child) end humFolder.ChildAdded:Connect(function(child) task.defer(function() -- Wait for model to fully load setupModelMonitoring(child) end) end) humFolder.ChildRemoved:Connect(function(child) cleanupModel(child) end)