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

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

Asked by 4 years ago

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

Log in to vote
0
Answered by
lunatic5 409 Moderation Voter
4 years ago

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.

0
I LITTERALY JUST SOLVED IT RIGHT BEFORE U ANSWERED XD coolmanHDMI 72 — 4y
0
hmm my answer was a little different tho but i guess i can try yours coolmanHDMI 72 — 4y
0
If you don't mind sharing what was the solution you came up with? lunatic5 409 — 4y
0
sure im gonna post it as an answer ok? coolmanHDMI 72 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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)

Answer this question