Here's the first way:

  • I have 10 parts called "KillBrick" they're put all around the workspace.
  • Each of them have this script inside:
local part = script.Parent
part.Touched:connect(function(toc)
	if not toc.Parent and toc.Parent:FindFirstChild('Humanoid') then return end
	local hum = toc.Parent.Humanoid
	hum.Health = 0
end)

Here's the second way:

  • I have 10 parts called "KillBrick" they're put inside a folder named "KillBricks" in the workspace.
  • Inside the folder also have just 1 script:
local folder = script.Parent
for i,part in pairs(folder:GetChildren()) do
	if part.Name == "KillBrick" then
		part.Touched:connect(function(toc)
			if not toc.Parent and toc.Parent:FindFirstChild('Humanoid') then return end
			local hum = toc.Parent.Humanoid
			hum.Health = 0
		end)
	end
end

So which one of the ways above is the best in improving performance? Both gameplay and server's response speed.

4 comments

1

The second way; looking through and connecting the event.

0

If you have any other suggestion or a better way to do it. Answer by taking one of the scripts above and improve it.

0

@TheeDeathCaster Can you explain how it will resolve the server's reponse speed faster than the first one?

0