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

TakeDamage is not a valid member of Part ??

Hi, i don't understand why i keep getting this error. I'm trying to make a script where you deal 10 damage when touching a part.

local Main = script.Parent

Main.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit:TakeDamage(10)
	end
end)

Also the script is inside a model as you can see here: (http://i.imgur.com/Hq4jPvJ.png)

The model contains a humanoid because i want it to display a name above it.

1 answer

✓ Accepted answer

Take Damage only works with a humanoid. You've done it with a part so it won't work. So you'll have to change hit:TakeDamage to hit.Parent:FindFirstChild("Humanoid"):TakeDamage 10, also I recommend maybe using a debounce system, as the touched event fires multiple times.

3 comments

0

Sorry im on mobile so it may not look right idrk

0

It worked! I appreciate your help.

0

np glad i could help

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