script.Parent.ClickDetector.MouseClick:Connect(function(c)
local cpart = game.Workspace:WaitForChild("notpart")
local part = cpart:Clone()
part:Destroy()
wait(.1)
cpart.Parent = workspace
end)
while true do
if game.Workspace:WaitForChild("boss") then
script.Parent.ClickDetector.MaxActivationDistance = 0
script.Parent.Color = Color3.fromRGB(255, 0, 0)
wait()
elseif game.Workspace:WaitForChild("boss") == nil then
script.Parent.ClickDetector.MaxActivationDistance = 32
script.Parent.Color = Color3.fromRGB(13, 105, 172)
wait()
end
end
there is a part named 'boss' in replicated storage, but when it is deleted, the rgb still remains 255, 0, 0 and the clickdetector does not fix

2 comments
You should use FindFirstChild just incase of infinite loops.
it's a part cloned through a different clickdetector, it's not in the workspace at all times