Mass Collisions with a single script?

I have a lot of parts(30+) that need collision/touch checks, and I need to be able to easily change them all, and I decided to go with rather then a script in each part, I would use one server script using a for loop going through the folder they’re all in.

This ended by bringing up some unwanted things though, as now the thing always happens at least .5 seconds AFTER they touch it, and since its a race obby, sometimes that’s the entire reason someone dies.

Currently I’m using :

local Parts = workspace.SpeedParts

local debounce = false

for i, v in pairs(Parts:GetChildren()) do
	v.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild("Humanoid") and not debounce then
			local human = hit.Parent:FindFirstChild("Humanoid")
			debounce = true
			human.WalkSpeed = human.WalkSpeed * 2
			wait(2)
			human.WalkSpeed = human.WalkSpeed / 2
			debounce = false
		end
	end)
end

(yes it repeats properly, that’s not a problem yet)

In short, I’m wondering if there is a faster way to do the touch checking, without having an individual script on each part?

1 Like

There is a service that you can use I believe however I did forget the name of it. But another solution would be to put this in a local script and use magnitude or raycasting over touched. Ill look around on wiki, if I happen to find that service ill come back send a message to you.

I believe you’re talking about PhysicsService

With PhysicsService you can create and manage collision groups.

My brother just gave me a solution, but I’ll still try that because you can never have too much knowledge of a programing language. thanks for your time. :slight_smile: