I need this coin to be destroyed when it touches any of these red zones, how would i do this?

  1. Use region3 to check if a coin has spawned in a zone
  2. Delete coin using coin:Destroy()
2 Likes

Region3 is deprecated according to roblox

I did not know that, but further investigation led me to this post:

Use this instead and you should be fine. If you dont want to, you can still use region3 but it will use more memory.

1 Like

Whenever you spawn a coin, check the parts that collide with it by using workspace:GetPartsInPart(coin)
If the part name/any other indicator you want that its the red zone align then destroy the coin

Put this inside your zone part:

local box = script.Parent

local function delete()
	local zone = workspace:GetPartsInPart(box)
	for i = 1, #zone do
		if zone[i].Name == "COIN" then
			zone[i]:Destroy()
		end
	end
end

What this does is go through all of the objects in the part and finds the ones named COIN. It then deletes those parts using the Destroy() function.

To trigger the function you could use a wait loop:

while wait(5) do
	delete()
end

or even better make a bindable event trigger every time you spawn a coin:

local coinSpawnEvent = -- The bindable event
	
coinSpawnEvent.Event:Connect(delete)

(edit)
More about bindable events:
BindableEvent (roblox.com)
They behave like remote events but only for passing messages from one server script to another.

1 Like