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

The script itself doesn't destroy itself?

I tried making the trigger part do their function and stuff, after .97 seconds, the script doesn't destroy itself, but the functions came in. I wonder what I have done wrong at this point?

script.Parent.Touched:connect(function(hit)
	script.Sound:Play()
	script.Parent.Parent.DoorClose.Union.Transparency = 0
	script.Parent.Parent.DoorClose.Union.Part.PointLight.Enabled = true 
	script.Parent.Parent.DoorClose.Union.Part.Transparency = 0
	script.Parent.Parent.DoorOpen.Union:Destroy()
	script.Parent.Parent.DoorOpen.Union.Part:Destroy()
	wait(.97)
	script:Destroy()
end)

2 comments

1

why destroy the script when u can simply disable it or use a debounce to disable the script without disabling or destroying the script?

0

I'm new to script so. I wouldn't understand that much. Thing is, this is a trigger part. So once its touched and done it's functions, it can be disabled or destroy. However, it doesn't do these things.

2 answers

Nvm, I fixed it thanks to greatneil80. I added debounced and it worked out smoothly.

There is a disabled property in scripts. Simply do this. Is this what u needed?

script.Parent.Touched:connect(function(hit)
    script.Parent.Script.Disabled = false
    script.Sound:Play()
    script.Parent.Parent.DoorClose.Union.Transparency = 0
    script.Parent.Parent.DoorClose.Union.Part.PointLight.Enabled = true 
    script.Parent.Parent.DoorClose.Union.Part.Transparency = 0
    script.Parent.Parent.DoorOpen.Union:Destroy()
    script.Parent.Parent.DoorOpen.Union.Part:Destroy()
    wait(.97)
    script.Parent.Script.Disabled = true
end)

6 comments

0

No, it doesn't solved it.

0

It would be weird to put it that way though.

0

You said script.Parent.Parent which is the door? So you're trying to disable the door. Not the script.Disabled.

0

Door has nothing to do with the script itself being destroyed. topic close.

0

I just based it off the script up the top, Jeez.

0

Its not my fault I just copied the script up top and modified it.

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