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

Can anyone help me with FindFirstChild?

Asked by 10 years ago
local humanoid = script.Parent:FindFirstChild("Humanoi­d")

function onTouched(hit)--

if hit.Parent.Name == "Tree" then
    hit.Parent.health.Value = hit.Parent.health.Value - 1

if hit.Parent.health.Value < 1 then
    hit.Parent:Remove()    **--It gets up to here, but no 'Wood' is added**
    humanoid.Parent.leaderstats.Wood = humanoid.Parent.leaderstats.Wood + math.random(7,13)
end 
end
end

connection = script.Parent.Touched:connect(onTouched)

this script works till line 9, but after no wood is added, why is this?

0
works till line 9* the tree is successfully removed Shaydesilva 85 — 10y

1 answer

Log in to vote
-1
Answered by 10 years ago
humanoid.Parent:GetPlayerFromCharacter().leaderstats.Wood = humanoid.Parent:GetPlayerFromCharacter().leaderstats.Wood 

instead of

~~~~~~~~~~~~~~~~~ humanoid.Parent.leaderstats.Wood = humanoid.Parent.leaderstats.Wood + ~~~~~~~~~~~~~~~~~

0
sorry it seems to have cut part of the script out, ill make the necessary changes, please check again Shaydesilva 85 — 10y
0
+ math.random(7,13) has been moved to the next line so it is displayed Shaydesilva 85 — 10y
Ad

Answer this question