Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can anyone help me with FindFirstChild?

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?

1 comment

0

works till line 9* the tree is successfully removed

1 answer

humanoid.Parent:GetPlayerFromCharacter().leaderstats.Wood = humanoid.Parent:GetPlayerFromCharacter().leaderstats.Wood 

instead of

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

2 comments

0

sorry it seems to have cut part of the script out, ill make the necessary changes, please check again

0
  • math.random(7,13) has been moved to the next line so it is displayed

This discussion is preserved as it was. New answers, comments, and votes are closed.