I am new to scripting and have attempted to make a kill effect for the linked sword. This is what I have come up with:
character:FindFirstChild("Humanoid").Health <= 0 then script.Parent.Humanoid.Died:connect(function(Plr) for i, v in pairs(workspace:WaitForChild(script.Parent.Name):GetChildren())do if v:IsA("Accessory") then v.Handle.Anchored = true elseif v:IsA("MeshPart") then v.Anchored = true elseif v:IsA("UnionOperation") then v.Anchored = true elseif v:IsA("Part") then v.Anchored = true end end for i = 1,20 do wait(0.0025) for i, v in pairs(workspace:WaitForChild(script.Parent.Name):GetChildren())do if v:IsA("Accessory") then v.Handle.Transparency = v.Handle.Transparency + 0.05 elseif v.Name == "Head" then v.Transparency = v.Transparency + 0.05 v.face.Transparency = v.face.Transparency + 0.05 elseif v:IsA("MeshPart") then v.Transparency = v.Transparency + 0.05 elseif v:IsA("UnionOperation") then v.Transparency = v.Transparency + 0.05 elseif v:IsA("Part") then v.Transparency = v.Transparency + 0.05 end end end end)
I have put this in the SwordScript underneath:
local character = Hit.Parent if character == Character then return end
Can someone please explain what I have done wrong.
There Is a Humanoid event called .Died()
More Information can be seen here:
https://developer.roblox.com/en-us/api-reference/event/Humanoid/Died