Error while looping

Hello, the lost people,

I am working on item interaction for my new game. But the TouchTransmitter remover script got error in the output. I want to fix this ASAP. Hope you can help :>

Script:

local function removeTouchTransmitterFrom(object)
	for index, target in pairs(object.Handle:GetDescendants()) do
		if target:IsA("TouchTransmitter") then
			target:Destroy()
		end
	end
end

for _, item in pairs(CollectionService:GetTagged("Item")) do
	while true do
		removeTouchTransmitterFrom(item)
	end
end

Output:
image

2 Likes

Do While wait() do, also RunService would be better.

Use while wait(1)

while wait(1)
-- Your Code
end

This would solve the error in the output, but there’s another bug in the script because the while loop is inside the for loop. The script runs the for loop once then gets stuck on that single while loop forever.

I’m imagining OP wants to move the while loop outside the for loop to infinitely repeat the code.

2 Likes