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)
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.
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)