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

Script supposed to delete it's parent and enable a GUI doesn't work, help ?

script.Parent.Touched:connect(function()
	 script.Parent:Destroy();
	 script.Parent.Parent.Parent.StarterGui.ScreenGui.Enabled = true
end)

This script is supposed to delete it's parent and enable a GUI, but it won't work,. Any help ?

2 answers

You need to Enable script before deleting its parent, you will delete this script after deleting its parent and you cant enable other script man :/

script.Parent.Touched:connect(function()
	script.Parent.Parent.Parent.StarterGui.ScreenGui.Enabled = true --First This
     script.Parent:Destroy()
end)

First think about your script dude. If you break down your script it's saying "When the parent is Touched, destroy the parent AND THEN enable the GUI. The fix is easy just flip em around." Just use this,

script.Parent.Touched:connect(function()
	script.Parent.Parent.Parent.StarterGui.ScreenGui.Enabled -- Start with this so you don't delete your GUI you want to enable
	script.Parent:Destroy()
end)

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