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

How do I get the door to open after a certain npc dies?

So im trying to make sorta like a dungeon crawler, but i need the door to open after the npc dies. This is my attempt the door opening script.

script.Parent.Transparency = 0.5
script.Parent.CanCollide = false
wait(1)
script.Parent.Transparency = 0
script.Parent.CanCollide = true

and this is the script i made to open the door when the npc dies.

local part1 = game.Workspace.part1
local part2 = part1.you.Disabled
function door()
	local hp = script.Parent.Health
	if hp <1 then
		part2 = false
	end	
script.Parent.Died:Connect(function(door)

(part 1 is the door) (the door opening script is disabled) (the second script is supposed to enable the first script when the npc dies) (i put the second script in the npc's humanoid)

2 answers

✓ Accepted answer

You shouldn't need two scripts for this. Here's a short script that should work when placed inside of the NPC:

script.Parent.Humanoid.Died:Connect(function()
	door.Transparency = 0.5
	door.CanCollide = false
end)

All you need to do is replace "door" with the actual door. For example, if it's in Workspace and called "Door" you would write the following:

script.Parent.Humanoid.Died:Connect(function()
	game.Workspace.Door.Transparency = 0.5
	game.Workspace.Door.CanCollide = false
end)

Hope this helps.

4 comments

0

I LITTERALY JUST SOLVED IT RIGHT BEFORE U ANSWERED XD

0

hmm my answer was a little different tho but i guess i can try yours

0

If you don't mind sharing what was the solution you came up with?

0

sure im gonna post it as an answer ok?

Heres what I got after troubleshooting.

function door()
local partsboi = game.Workspace.part1
local LOL = script.Parent.Health
if LOL <1 then
	partsboi.Transparency = 0.5
	partsboi.CanCollide = false
	wait(5)
	partsboi.Transparency = 0
	partsboi.CanCollide = true
end
end
script.Parent.Died:Connect(door)

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