I have a part script that kills you while you’re holding or equipping a harmed tools such as guns or whtever whenever in Church
But I don’t know why it kills me while equipping a weapon even outside while I didn’t touch the part.
The script looks like this
local Blacklisted_Tools = {
"MAD DEAGLE",
"california",
"9mm",
"M16",
"Uzi",
"london"
}
local Death = game.ReplicatedStorage:WaitForChild("Death_Reason")
local Text = "NO HARM TOOLS ARE ALLOWED IN CHURCH!"
script.Parent.Touched:Connect(function(BasePart)
local Guy = BasePart.Parent:FindFirstChild("Humanoid")
if Guy and Guy.Parent:IsA("Model") then
local Char = Guy.Parent
local Tools = Char:FindFirstChildWhichIsA("Tool")
for i = 1,#Blacklisted_Tools do
if Tools and string.upper(Tools.Name) == string.upper(Blacklisted_Tools[i]) then
Guy.Health = 0
if not BasePart.Parent.Head:FindFirstChild("Death_Reason") then
local DClone = Death:Clone()
DClone.Parent = BasePart.Parent:FindFirstChild("Head")
DClone.TextLabel.Text = Text
end
else
Char.ChildAdded:Connect(function(child)
for i = 1,#Blacklisted_Tools do
if string.upper(child.Name) == string.upper(Blacklisted_Tools[i]) then
Guy.Health = 0
if not BasePart.Parent.Head:FindFirstChild("Death_Reason") then
local DClone = Death:Clone()
DClone.Parent = BasePart.Parent:FindFirstChild("Head")
DClone.TextLabel.Text = Text
end
end
end
end)
end
end
end
end)
Once fires ONCE in a section, so the thing you made doesnt change anything, it makes the player fire the event only once after he enters the church. Once doesnt check if ur inside or not
the inital problem is that when the player leaves,
Char.ChildAdded would still listen
so I guess:
local connection
local Blacklisted_Tools = {
"MAD DEAGLE",
"california",
"9mm",
"M16",
"Uzi",
"london"
}
local Death = game.ReplicatedStorage:WaitForChild("Death_Reason")
local Text = "NO HARM TOOLS ARE ALLOWED IN CHURCH!"
function childAdded(child)
for i = 1,#Blacklisted_Tools do
if string.upper(child.Name) == string.upper(Blacklisted_Tools[i]) then
child.Parent.Humanoid.Health = 0
if not child.Parent.Head:FindFirstChild("Death_Reason") then
local DClone = Death:Clone()
DClone.Parent = child.Parent:FindFirstChild("Head")
DClone.TextLabel.Text = Text
end
end
end
connection:Disconnect()
connection = child.Parent.ChildAdded:Connect(childAdded)
end
script.Parent.Touched:Connect(function(BasePart)
local Guy = BasePart.Parent:FindFirstChild("Humanoid")
if Guy and Guy.Parent:IsA("Model") then
local Char = Guy.Parent
local Tools = Char:FindFirstChildWhichIsA("Tool")
for i = 1,#Blacklisted_Tools do
if Tools and string.upper(Tools.Name) == string.upper(Blacklisted_Tools[i]) then
Guy.Health = 0
if not BasePart.Parent.Head:FindFirstChild("Death_Reason") then
local DClone = Death:Clone()
DClone.Parent = BasePart.Parent:FindFirstChild("Head")
DClone.TextLabel.Text = Text
end
else
connection = Char.ChildAdded:Connect(childAdded)
end
end
end
end)