Issue where parts flicker when touched

So I have an issue where tiles flicker while turning transparent. Is there any way to fix this? I tried using the debounce method but it didn’t work.

Here is the code for the parts:

for _,Part in ipairs(tileGameClone.TileLayer1:GetChildren()) do
				if Part:IsA("Part") then
					local debounce = false
					Part.OnTouchedTile.Touched:Connect(function(hit)
						if debounce == false then
							for i = 0, 1, 0.05 do
								Part.Transparency = i
								wait()
							end
							debounce = true
						end
						Part.CanCollide = false
						Part:Destroy()
						debounce = false
					end)
				end
			end

If you would kindly please help, I would be gladly appreciated it. If you need a better understanding of what my problem is, please feel free to tell me! If you need a video clip of the issue, please tell me I’m happy to do so!

Is this for a disappearing tile? Asking so I know what could be a possible solution for this

yes with many other tiles as well to reduce the amount of scripting.

Try this

for _,Part in ipairs(tileGameClone.TileLayer1:GetChildren()) do
	if Part:IsA("Part") then
		Part.OnTouchedTile.Touched:Connect(function(hit)
			if hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
				if Part.Transparency == 0 then
					for i = 0, 1, 0.05 do
						Part.Transparency = i
						wait()
					end
					Part:Destroy()
				end
			end
		end)
	end
end

This will make it so the hit code will only run if the Transparency of Part is 0, aka when it hasn’t began disappearing. I also moved the code outside of that if statement into it which I think is what you wanted to do. I removed the Part.CanCollide since destroying the part gets rid of it so players will fall through it anyways

1 Like

Thank you so much! Its fixed! I really appreciate your help!

Anytime! If you ever need anymore help with anything don’t be afraid to make another post!

1 Like