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

Local Script not finding object within its parent?

Asked by 3 years ago
Edited 3 years ago

I'm trying to reference a remote event from a local script, both the script and remote event are stored within the Tool, yet for some reason, I am getting this error " CurrentFuel is not a valid member of Tool "Players.generalYURASKO.Backpack.Lighter" and I don't understand why the script can't find the remote event. I know what a few of you are going to say, "You should keep remote events in replicated storage," but I've done it this way a few times before, and this is the first time I'm seeing this error. Any ideas?

1
Try adding in a :WaitForChild() statement to see if that works FrontsoldierYT 129 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

To add on what FrontsoldierYT said, the objects that you are trying to get have yet to load. Using the WaitForChild command will make sure that it gets the object as soon as it has loaded

local player = game.Players.LocalPlayer
local lighter = player.Backpack:WaitForChild("Lighter")
0
Yea, that did the trick. generalYURASKO 144 — 3y
Ad

Answer this question