-
Notifications
You must be signed in to change notification settings - Fork 0
/
Kill bricks.lua
38 lines (28 loc) · 887 Bytes
/
Kill bricks.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
--[[
!! Installation guide
This script will collect parts tagged with "Kill Parts"
- Set in TagName variable
- Depso
]]
----// Configuation
local TagName = "Kill Parts"
--// Services
local CollectionService = game:GetService("CollectionService")
--// The kill function itself
local function Touched(Limb)
local Character = Limb.Parent
if not Character then return end
local Humanoid: Humanoid = Character:FindFirstChildOfClass("Humanoid")
if not Humanoid then return end
Humanoid.Health = 0
end
--// Add connections for parts added
local function MemberAdded(Object: BasePart?)
if not Object:IsA("BasePart") then return end
Object.Touched:Connect(Touched)
end
--// Add connections for tag members
CollectionService:GetInstanceAddedSignal(TagName):Connect(MemberAdded)
for _, Object in next, CollectionService:GetTagged(TagName) do
MemberAdded(Object)
end