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

Having Parent problems?

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?

3 answers

✓ Accepted answer

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() 

3 comments

0

No, because when the tool is active it is not in the Backpack it is in the Character model. It goes into the backpack when it is not being used,

0

Fair enough. I can't help then sorry. Looks okay to me. (maybe try :Destroy() rather than (destroy) though? Not sure why it would throw that error)

0

Oops, I didn't see this comment, and I came to that same conclusion on my own. Changed it to :Destroy(0 and now it works. Thanks!

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()

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