How do I make a part appear when the rig or dummy is destroy or dead

Hi I am pretty new to script from scratch and I need help on how to create a script where if the dummy is dead, then the part in the same group as the rig will disappear.

This is what I have so far

part = script.Parent.Parent.Part

– Function to check health
local function checkHealth(character)
local humanoid = character:FindFirstChildOfClass(“Humanoid”)
if humanoid then
if humanoid <= 1 then
– make the Part in the group visable to 1
part.CanCollide = false
part.Transparency = 1

	end
end	

end

(I put the script in the dummy or rig and out side is that group that is just a part and the rig.)

2 Likes

there is something known as Humanoid.Died and it exists just for this reason

local part = path.to.part -- change this to wherever the part is
local character = path.to.dummy -- change this to wherever the dummy is
local humanoid = character:FindFirstChildOfClass(“Humanoid”)

-- function
local function Died()
    -- make the Part in the group visable to 1
    part.CanCollide = false
    part.Transparency = 1
    -- you can also use part:Destroy() if you want it completely gone
end	

humanoid.Died:Once(Died) -- this will do the function when humanoid.Health reaches 0
1 Like

Do I just put in your version and is putting the script in the dummy correct or should I put it outside of the dummy?

1 Like

I don’t think either will make a difference. You can just place it in the Dummy for organising your scripts, I guess.

1 Like

also is the code correct because it is not working for me unless if I have to include the code into my own code.

1 Like

Did you replace this part with the actual path to the Part/Character? You aren’t supposed to copy this part wholesale.

1 Like
part = script.Parent.Parent.Part
local Character = path.to.Dummy -- If the script is parented to the Rig then you can do script.Parent
local Humanoid = Character:FindFirstChild("Humanoid")

if Humanoid.Died:Connect(function()
part.CanColide = false
part.Transparency = 1
end)

1 Like


I copied the died function but it didn’t work for me, I think I am not correctly connecting the part in the group

1 Like

Is the Part located under the Model “RespawnDummy”?

If that’s the case, you will have to replcace the path to part with:

local part = script.Parent.Parent.Part
1 Like

Nevermind, I have mistaken myself in the original post it says Script.Parent.Parent.Parent

2 Likes

This script works, and I’ve tested it in studio

local Part = game.Workspace:FindFirstChild("PartName")

local Humanoid = script.Parent:FindFirstChild("Humanoid")

local function onHumanoidDeath()
	Part.CanCollide = true --// Make that you cannot walk through the part
	Part.Transparency = 1 --// Makes the part transparent.
end

Humanoid.Died:Once(onHumanoidDeath)
2 Likes

I think you forgot to use function when humanoid’s health is changed

local function checkHealth(character)
local humanoid = character:FindFirstChildOfClass(“Humanoid”)
if humanoid then
if humanoid.Health <= 0 then
part.CanCollide = false
part.Transparency = 1

	end
end	
end

Script.Parent.Humanoid.HealthChanged:Connect(checkHealth)

(Srry if i understanded something wrong cause I’m bad at english lol, but I hope it helps you, tell me if theres any issues)

1 Like

This does not state the Humanoid’s Health that’s an issue.

2 Likes

Ohhh I forgot lol, sorry about that, and I think I know other issues

1 Like

It should be

local function checkHealth()

local Humanoid = script.Parent:FindFirstChild("Humanoid")

if Humanoid.Health == 0 then
Part.CanColide = false
Part.Transparency = 1 
end

script.Parent.Died:Once(checkHealth)
1 Like

Yeah that could be work, I’m just bad too lol

1 Like

As the >= means (equal or less than), we don’t really need it as == means equal to so as the Dummy (rig)'s health equals to 0 then we don’t need the Rig’s Health >= less than or equal to 0

1 Like

My scripts work, he’s just not solutioning them.

1 Like

sorry I am doing it while in class I am trying to get to work but I think I am reading it wrong so far

The script’s work, just copy them and solution which one works.

1 Like