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 Model?

I've made a box that spawns infront of the player and damages any other players, however instead of damaging players I just get this error: "TakeDamage is not a valid member of Model"

local HB = game.ServerStorage.HB1:WaitForChild("H1")
			local Character = player.Character
			local Hitb = HB:Clone()
			Hitb.CFrame = Character.HumanoidRootPart.CFrame * CFrame.new(0,0,-5)
			Hitb.Parent = workspace
			
			Touch = Hitb.Touched:connect(function(hit)
				if hit.Parent:FindFirstChild("Humanoid") then
					if hit.Parent.Name ~= player.Name then
						hit.Parent:TakeDamage(15)
						if Touch ~= nil then Touch:Disconnect() end
						Hitb:Destroy()
					end
				end
			end)

2 comments

0

It might be because you're doing hit.Parent:TakeDamage(15), and what it looks like, that is refering to the Character, not the players humanoid. I could be wrong.

0

I'd also like to recommend you use FindFirstChildOfClass("Humanoid") just to make sure that what you are trying to damage is, in fact, a Humanoid

1 answer

✓ Accepted answer

You did hit.Parent which is just the Character. You have to do hit.Parent.Humanoid:TakeDamage(15)

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