Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
0
Answered by
WoTrox 345 Moderation Voter
4 years ago
Edited 4 years ago

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

0
Thank you very much! PhacYouBeech 17 — 4y
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... User#834 0 — 4y
0
It completes the same task. The if statement is unnecessary tho but it has little to no interference with the script. JustinWe12 723 — 2y
Ad
Log in to vote
0
Answered by 4 years ago

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.

Answer this question