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

How to set a tools parent with a normal script?

Asked by 5 years ago
Edited 5 years ago

I've been at it hours trying to fix"ITEM is not a valid member of Backpack",but when i look the item is still in the backpack in current server and client. I don't know anymore, help?

1 answer

Log in to vote
0
Answered by
Mr_Unlucky 1085 Moderation Voter
5 years ago

Even though my answer is considered a comment, I'lll try to explain why.

The reason why is that the object hasn't loaded into the backpack yet. Try using :WaitForChild()

WaitForChild()

For example, we can do a LocalScript inside StarterPlayerScripts.

local Player = game:GetService("Players").LocalPlayer

local Tool = Player.Backpack:WaitForChild("Tool")

--Random code here and stuff lol

This is a hypothetical situation in which we want to find the Tool inside the Player's backpack.

I usually get a lot of errors in my games for not finding a specified object in a specific place but using WaitForChild() can help.

Click here for the developer wiki page. Good luck on your game!

0
OMG THANK YOU IT FINALLY WORKED AFTER @% hours of trying i have just to use wait for child! TANK YOU! NungkiceNicekung 22 — 5y
Ad

Answer this question