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

how to fix these Ongoing problems with getting child from parent?

Asked by 1 year ago

I'm having problems on getting a child. I know how to do it its just giving me an error.

0
Can you like show us what your code is? And what is the error? menofmen1234 20 — 1y
0
I have a code in starter character scripts making a boolvalue from instance inside the character and in my main code I try to get that value using Plr.Character.BoolValue.Value = true but it gives and error saying BoolValue is not a member of Plr.Character masilasi2008 10 — 1y

2 answers

Log in to vote
0
Answered by 1 year ago

This error usually boils down to two things. -You are trying to assign the value of an object instead of the property (ex part = true) -You are trying to index a child in a localscript

to fix the bottom issue which is probably what your experiencing is to use WaitForChild as when localscripts are initialized they are still replicating objects from server to client so there are times in which a localscript can't find a certain object when running.

If you are doing this

Plr.Character.BoolValue.Value = true

switch it to

Plr.Character:WaitForChild("BoolValue").Value = true

I also suggest putting things like characters into variables as you use them quite frequently and makes it easier to read :)

Ad
Log in to vote
0
Answered by 1 year ago

I saw your comment and what I recommend is doing this:

When you create your bool value using Instance, you should make that new instance a variable. Like this:

local BoolValue = Instance.new("BoolValue")

And then later when you want to change the value of the boolean you can do this:

BoolValue.Value = true

This makes it much easier and your script a little shorter. Hope this helps!

Answer this question