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

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

Asked by 4 years ago
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

Log in to vote
0
Answered by
enes223 327 Moderation Voter
4 years ago

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)
Ad
Log in to vote
0
Answered by
acuaro 29
4 years ago

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)

Answer this question