Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

how to make a block in a game non transparent after npc is killed?

I really suck at scripting but how do I make it so when an npc is killed,a block that is transparent becomes non transparent and reappears. For example, when I kill an npc, I want this checkpoint to appear.

I think I have the script but I don't know how to use it.

NPC.Humanoid.Died:Connect(function()
    part.Transparency = 0
end)

2 answers

✓ Accepted answer

First we need the NPC and the part

local NPC = workspace.NPC or workspace:waitForChild("NPC") -- Change the "NPC" to your likes
local part = workspace.ThePart or workspace:WaitForChild("ThePart") -- Make sure that the part's name is not "Part", change it to anything else, like "ThePart"

NPC.Humanoid.Died:Connect(function()

	if NPC.Humanoid.Health <= 0 then
	
		part.Transparency = 0
	
	end

end)

Paste this inside a normal (server) Script, into the workspace. I hope this works

3 comments

0

Thank you very much!

0

How is this the accepted answer, you literally perform an if check for the humanoid health whilst if he's dead his health is already 0...

0

It completes the same task. The if statement is unnecessary tho but it has little to no interference with the script.

The script is correct, just paste it somewhere in a script and make sure to set NPC and part to the correct instances. For example if the script is within the NPC then NPC would be local NPC = script.Parent and part would be local part = game.Workspace.Part -- or whatever the other part is named.

This discussion is preserved as it was. New answers, comments, and votes are closed.