So a friend is wondering what will perform the fastest make a brick kill a character. We think the collection service but there is a lot of ways to do things so is there something else?
Using CollectionService probably would be the best approach for the job. It’s about as easy and intuitive as it gets.
local killbrickConnections = {} --Keep a table of connections to disconnect later!!
local function onTouch(hit)
--Do What Every other script does
end
for _,killbrick in pairs(game:GetService("CollectionService"):GetTagged("Kill Brick")) do
local connection = killbrick.Touched:Connect(onTouch)
table.insert(killbrickConnections,connection)
end
To clearify, we know how to script it, our only question is about what would be the fastest with peformance.
I’m not sure the “performance” of a kill brick is something worth considering. Why do you think this?
I mean like how you can prevent it from making the game lag.
A kill brick shouldn’t be making the game lag. The problem lies elsewhere most likely.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
script.Parent.Touched:Connect(function()
char.Humanoid.Health = (0)
end)
end)
end)
That’s what I would do
Please don’t, that will make a lot of RBXScriptConnection and possibly consume a ton of server memory. You are basically telling the server, “Hey make another event when a new player joins”.
To the @OP and his @friend. I suggest using CollectionService or keep all the KillBricks in a Folder.
Why? Getting every part in a variable is so tedious, and sometimes you can’t even understand your script anymore.
Oh, sorry I didn’t know that.
Thanks for letting me know
A kill brick will not cause server lag, even I, a Builder and not a programmer would know that! Try using the ROBLOX Tutorial Kill Brick Script, it won’t make lag.
But, if you’re making a detailed obby make sure not to use that much parts, that will cause lag!
Use meshes or most importantly, blender to make meshes. That will lower the part count by alot and will improve performance.
Most lag comes from unanchored objects and from just the game itself if it has a lot of parts. Refrain from using too much parts at all costs.
not lag. read the question again.
Try using collection service which will allow to you to mantain all kill bricks with only 1 script.
Yeah what I was thinking. But this was for a friend and he was asking bc he was taking a new quiz and wanted to make sure that was the answer.