Heal is not a valid member of Tool

So I have this problem with a healing tool, it’s supposed to heal you but I get the error
'Heal is not a valid member of Tool

So what’s happening is:

  • Player does not recieve +25 HP

  • Particles do not emit (may be another problem but I’m new to coding)

Here is the Output:

Here is the Code:

script.Parent.Heal.OnServerEvent:Connect(function(player)
	local char = player.Character or player.CharacterAdded:Wait()
	local humrp = char:FindFirstChild("HumanoidRootPart")
	local humanoid = char:FindFirstChild("Humanoid")
	
	local particles = script.ParticleEmitter:Clone()
	particles.Parent = humrp
	particles:Emit(25)
	
	humanoid.Health += 25
end)

If anyone has a good way of explaining ‘example’ is not a valid member of ‘example’
I’d love to hear! I had the same situation a few days back but couldn’t understand how to fix it this time.

Any help is appreciated :smile:

1 Like

Can you show me the hierarchy of ~.Backpack.Hotdog item?

local Heal = script.Parent:WaitForChild("Heal")
assert(Heal)
Heal.OnServerEvent:Connect(function(player)

I was thinking this too … Also assert will throw an error it not true.
So, @Duck keep in mind this is a diagnostic call. If that works you may not want to include that line.

1 Like

That’s the whole point of assert…?
The code will error next line either way, if it doesn’t exist…

image_2023-08-26_170538027

Is this what you mean? Sorry I had to google the definition of hierarchy and I think this is what you mean.

Ah, so your tool is missing the RemoteEvent named Heal. If you insert it and name it exactly that, it would retain its original function. It should be directly under Hotdog, not any of its descendants.

2 Likes

This helped remove the error in output, However the issue is still happening.

1 Like

Im pretty sure you blindly copied code from someone. Putting a remote event in a tool overal, is not the smartest thing to do. And you don’t even got it in your tool

1 Like

Depends on how you look at it. I followed a tutorial on how to do it because I’ve only been coding for around 2 months and still am learning. I thought I said that in the original post.

1 Like

like someone said in my post, this is why you dont follow full tutorials, but learn how to script instead. if you dont know what youre doing then theres little to no chance of finding out what you did wrong.

1 Like

How do I learn a language without a class, or tutorials?

There’s nothing wrong with watching tutorials at the start, that’s how you learn. eventually you should 100% branch off and do things independently, but that’s hard for a complete beginner. It’s hard to go off on your own when you can’t even walk.

2 Likes

are you creating anything on the client side that the server cant access?

yeah, but when you write scripts without knowing what they do it becomes kinda hard to learn (Atleast in my opinion)

So I finally figured this out, I decided to use the game Scripting School for some help on things I didn’t understand, Followed a tutorial and read some forum posts and I have this to heal the player:

local tool = script.Parent

tool.Activated:Connect(function()
	local humanoid = tool.Parent:FindFirstChild("Humanoid")
	humanoid.Health = humanoid.Health + 25
end)

So according to my non-existent coding knowledge that should be all you need to make a basic heal tool.

Thanks for the help.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.