I want to destroy a script inside a Tool from a script inside a Textbutton.
script.Parent.Parent.Parent.Parent.Parent.Character.Tool.GuiAppear(Destroy) --Starting script > TextButton > Frame > ScreenGui > PlayerGui > Player > Player's Character > Tool > Script I want to destroy.
I don't see anything wrong with my line of script, but every time I try and use it it gives me the error message "attempt to index field 'Parent' (a nil value)"
What's wrong?
If you have a tool, surely it would be in backpack not character?
so this might work?
script.Parent.Parent.Parent.Parent.Parent.Backpack.Tool.GuiAppear:Destroy()
Turns out the problem was that I just have a weird typo... I have it written as (Destroy)
at the end instead of :Destroy()
. Have no idea how I did that.
So many parents! Try this
This has to be in a LocalScript:
game.Players.LocalPlayer.Character.Tool.Gui.Remove()