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

Having Parent problems?

Asked by
emite1000 335 Moderation Voter
10 years ago

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

Log in to vote
2
Answered by 10 years ago

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() 
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, emite1000 335 — 10y
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) MasterDaniel 320 — 10y
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! emite1000 335 — 10y
Ad
Log in to vote
0
Answered by
emite1000 335 Moderation Voter
10 years ago

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.

Log in to vote
-1
Answered by 10 years ago

So many parents! Try this

This has to be in a LocalScript:

game.Players.LocalPlayer.Character.Tool.Gui.Remove()

Answer this question