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

findfirstchild is not a valid member of .....?

Asked by 6 years ago

Hey all,

I've got a persistent error I just can't get to the bottom of. I'm running a script in a model to try and get it to disappear (and not be harvestable) when it's reduced to 0 HP. I keep getting a first child error on the second line and can't resolve it by shifting the hierarchy around. Any ideals?

local Object = script.Parent local HP = Object:findfirstchild(HP) local MaxHP = Object:findfirstchild(MaxHP) local Model = Object:findfirstchild(Model) local CanHarvest = Object:findfirstchild(Model)

if HP == 0 then Model.Transparency = 1 Model.CanCollide = false canHarvest.Value = true wait(5) canHarvest.Value = true partTouched.Transparency = 0 partTouched.CanCollide = true HP.Value = MaxHP.Value

end

1
It's `FindFirstChild()`. Note the capitalization. RayCurse 1518 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Also try using the Code block button 'LUA icon' and insert your code on it, it makes life easier. use Object:FindFirstChild("HP") instead of Object:findfirstchild(HP) So your code is gonna be like that:

01local Object = script.Parent
02local HP = Object:FindFirstChild("HP")
03local MaxHP = Object:FindFirstChild("MaxHP")
04local Model = Object:FindFirstChild("Model")
05local CanHarvest = Object:FindFirstChild("Model")
06 -- There are 2 objects called Model the script won't work until you change one of them
07 
08if HP == 0 then
09    Model.Transparency = 1
10    Model.CanCollide = false
11    canHarvest.Value = true
12        wait(5)
13    canHarvest.Value = true
14    partTouched.Transparency = 0
15    partTouched.CanCollide = true
16    HP.Value = MaxHP.Value
17end
0
Thanks for the quick answer, that's really useful michael00075892 0 — 6y
0
Please accept his/her answer. So both of you can get reputation :) SirDerpyHerp 262 — 6y
Ad

Answer this question