I am making one kill effect and when the humanoid dies I want to change the character transparency to 1 (everything inside it but the kill effect part with SurfaceGuis dont change transparency)
one gif just for see one exemple:
basicly faces, hats everything like that doesnt change…
The script:
local tool = script.Parent
local Effect = game.ReplicatedStorage.DeletePart
local Sound = game.Workspace.SoundEffect
local debounce = false
--------------------------- here the kill effect function------------------------------
tool.HammerParts.HitPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Humanoid.Health <= 0 then
Sound:Play()
debounce = true
local character = hit.Parent
local humanoid = character.Humanoid
Sound.Parent = character
humanoid.BreakJointsOnDeath = false
humanoid.Died:Connect(function()
local torso = character.Torso
local humanoidRootPart = character.HumanoidRootPart
humanoidRootPart.Anchored = true
local EffectClone = Effect:Clone()
EffectClone.Parent = character
EffectClone.Position = torso.Position
for i,v in pairs(character:GetChildren()) do
v.Transparency = 1
end
debounce = false
end)
end
end)
----------------------------------------------------------------------------------------
Also how I can play the sound only when the humanoid dies because the sound only plays when the character is gone…
local tool = script.Parent
local Effect = game.ReplicatedStorage.DeletePart
local Sound = game.Workspace.SoundEffect
local debounce = false
--------------------------- here the kill effect function------------------------------
tool.HammerParts.HitPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Humanoid.Health <= 0 then
Sound:Play()
debounce = true
local character = hit.Parent
local humanoid = character.Humanoid
Sound.Parent = character
humanoid.BreakJointsOnDeath = false
humanoid.Died:Connect(function()
local torso = character.Torso
local humanoidRootPart = character.HumanoidRootPart
humanoidRootPart.Anchored = true
local EffectClone = Effect:Clone()
EffectClone.Parent = character
EffectClone.Position = torso.Position
for i,v in pairs(character:GetChildren()) do
v:Destroy()
v.Transparency = 1
end
character.Head.face:Destroy()
debounce = false
end)
end
end)
Use GetDescendants instead, for accessories you can destroy them.
for i,v in pairs(character:GetDescendants()) do
if v:IsA("Decal") or v:IsA("BasePart") then
v.Transparency = 1
elseif v:IsA("Accessory") then
v:Destroy()
end
end
local tool = script.Parent
local Effect = game.ReplicatedStorage.DeletePart
local Sound = game.Workspace.SoundEffect
local debounce = false
--------------------------- here the kill effect function------------------------------
tool.HammerParts.HitPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Humanoid.Health <= 0 then
Sound:Play()
debounce = true
local character = hit.Parent
local humanoid = character.Humanoid
Sound.Parent = character
humanoid.BreakJointsOnDeath = false
humanoid.Died:Connect(function()
local torso = character.Torso
local humanoidRootPart = character.HumanoidRootPart
humanoidRootPart.Anchored = true
local EffectClone = Effect:Clone()
EffectClone.Parent = character
EffectClone.Position = torso.Position
for i,v in pairs(character:GetChildren()) do
if v:IsA("BasePart") then
v:Destroy()
v.Transparency = 1
end
end
character.Head.face:Destroy()
debounce = false
end)
end
end)
Just replace the loop that changes the transparency of the character from “GetChildren” to “GetDescendants”, it will loop through every part in the character
tool.HammerParts.HitPart.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Humanoid.Health <= 0 then
Sound:Play()
debounce = true
local character = hit.Parent
local humanoid = character.Humanoid
Sound.Parent = character
humanoid.BreakJointsOnDeath = false
humanoid.Died:Connect(function()
local torso = character.Torso
local humanoidRootPart = character.HumanoidRootPart
humanoidRootPart.Anchored = true
local EffectClone = Effect:Clone()
EffectClone.Parent = character
EffectClone.Position = torso.Position
for key, object in pairs(character:GetDescendants()) do
if object:IsA("BasePart") then
object.Transparency = 1
elseif object:IsA("Decal") then
object.Transparency = 1
end
end
debounce = false
end)
end
end)