local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
for i, v in pairs(character:GetChildren()) do
if v:IsA("Part") then
v.Color = Color3.new(0,0,0)
if v.Name == "Torso" then
for i, b in pairs(v:GetChildren()) do
if b:IsA("ParticleEmitter") or b:IsA("PointLight") then
b.Enabled = false
end
end
end
end
end
end)
#how do i make this cleaner
1 messages · Page 1 of 1 (latest)
** You are now Level 4! **
What?? You code is fine and you compare it to yandere dev???
Who's yandere dev?
don't chain like that the conditions
pairs is useless tho
What's the difference between pairs and no pairs
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
for _, part in ipairs(character:GetDescendants()) do
if part:IsA("Part") then
part.Color = Color3.new(0, 0, 0)
elseif (part:IsA("ParticleEmitter") or part:IsA("PointLight")) and part.Parent.Name == "Torso" then
part.Enabled = false
end
end
end)
this is not the same
Because of Descendants?
looping through all descendants may be less efficient
ok ty