Help with Script error

Hello reader! For the past few days, I have been getting this

Script - Roblox Studio 4_6_2021 2_55_49 PM

I am not the most experienced with scripting, so that might be the issue. I have looked up what the error message means, and I think it might be a bug, but I’m not sure. Thanks for reading!

1 Like

Change Dummy:Destroy() to workspace.Dummy:Destroy()

This happens because “Dummy” was never defined, and the compiler thinks you are addressing a nonexistent variable.

4 Likes

Right when I test it, both the dummy and the door disappear. Is that supposed to happen?

Yea, you called the Destroy method on them.

1 Like

Ok, I’m trying to make it so that when the player kills the dummy, the door disappears. Probably should have said that in the post

script in a dummy:

script.Parent.Humanoid.Died:Connect(function()
       workspace.Door:Destroy()
      script.Parent:Destroy()
end)
2 Likes

There is no variable named “Dummy” in your script.

1 Like

Ok, I see. Thanks for telling me

game.Workspace.Dummy.Humanoid.Died:Connect(function()
	workspace.Door:Destroy()
end)
1 Like

Also if you want to you can make it a global using

_G
1 Like

That makes the dummy disappear on death (which is still useful, thanks). I’m trying to make the door disappear when the dummy dies

Oh wait nvm, It worked. Thanks a ton!

So just delete the line of code destroying it.
You’re welcome!

1 Like

In this scenario, using _G to define the dummy would have no use, since you can just as easily do
local Dummy = workspace:WaitForChild('Dummy'), and it would be about 30% faster (according to roblox)

1 Like