script.Parent.box.Touched:connect(function(hit) if hit and hit.Parent and hit.Parent:FindFirstChild'Humanoid' and hit.Parent.Humanoid:FindFirstChild'bullets' then print(hit.Parent.Name) -- Player1 if hit.Parent:FindFirstChild'Humanoid' then print(hit.Parent.Humanoid.Name) -- Humanoid end if script.Parent.Type.Value == 'Health' and hit.Parent.Humanoid.Health < hit.Parent.Humanoid.MaxHealth then hit.Parent.Humanoid.Health = script.Parent.Humanoid.Health + 1.5 script.Parent:Destroy()
The line that adds 1.5 health to the humanoid errors saying humanoid is not a valid member when it has already said it exists several times before, plain and simple. Help?
I'm assuming this is not the full script (like you didn't put the ends in your question). I just added the end
s in there just in case.
You've accessed the humanoid as hit.Parent.Humanoid
in all the lines before, and on the line in question, you have it as script.Parent.Humanoid
. This is probably a syntax error and you accessed the wrong instance's parent.
Fixed Code:
script.Parent.box.Touched:connect(function(hit) if hit and hit.Parent and hit.Parent:FindFirstChild'Humanoid' and hit.Parent.Humanoid:FindFirstChild'bullets' then print(hit.Parent.Name) -- Player1 if hit.Parent:FindFirstChild'Humanoid' then print(hit.Parent.Humanoid.Name) -- Humanoid end if script.Parent.Type.Value == 'Health' and hit.Parent.Humanoid.Health < hit.Parent.Humanoid.MaxHealth then hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health + 1.5 --You had script.Parent.Humanoid. script.Parent:Destroy() end end end)
If I helped you out, be sure to accept my answer!