How do I make a script that is constantly checking if there is a part?

How do I make a script that is constantly checking if there is a part in a parent and if it disappears it also detects it

try many ways but it doesn’t work. i try with while loop and if statement

(im new in scripting lol)

1 Like

I think these two events might help you with that.
https://developer.roblox.com/en-us/api-reference/event/Instance/ChildAdded
https://developer.roblox.com/en-us/api-reference/event/Instance/ChildRemoved

1 Like

or this one
https://developer.roblox.com/en-us/api-reference/event/Instance/AncestryChanged

1 Like

https://developer.roblox.com/en-us/api-reference/event/Instance/DescendantAdded
https://developer.roblox.com/en-us/api-reference/event/Instance/DescendantRemoving

and 2 more.

local Model = workspace:WaitForChild("Model")

Model.ChildRemoved:Connect(function(child) --model loses a child
	if child.Name == "put part name here" then --lost child matches some particular part
		--do stuff
	end
end)
1 Like