Is this good practice?

will this code affect negatively game perfomance?

local detectionPart = workspace:WaitForChild("Cartonete"):WaitForChild("Detetor") 

local function checkPartsInPart()
	local partsInRegion = workspace:GetPartsInPart(detectionPart)
	for _, part in ipairs(partsInRegion) do
		if part:IsA("BasePart") and part.Name == "Cart" then
			print("Cart Touched!")
		
		end
	end
end


while true do
	checkPartsInPart()
	wait(0.1) -- Check every 0.1 second; ad
end

Not that much but yes it will still affect the game performance a little bit.

1 Like

The check speed could but I’d say its alright.

1 Like