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

How do I fix, "Humanoid is not a valid member of Accessory?"

I'm made a part so that whenever you touch it, you get set on fire and take damage. But it's not working and there's an error in the output saying Humanoid is not a valid member of Accessory. Here's my script.

local value = script.Value.Value

script.Parent.Touched:Connect(function(hit)
	local humanoid = hit.Parent.Humanoid
	if humanoid then
		if value == false then
			value = true
			local fire  = Instance.new("Fire")
			fire.Enabled = true
			fire.Position = hit.Position
			fire.Heat = 5
			fire.Size = 10
			local function dmg()
				if value == true then
					humanoid.Health = humanoid.Health - 12.5
					wait(2)
				end	
			end
		end
	end	
end)

1 comment

0

Nvm I solved the problem. Turns out, the error in the output literally didn't affect anything. I came to find out that the real error was that fire doesn't have a property called "Position" so instead, I parented the fire to the "hit."

1 answer

You checked whether the hit is a player or not after defining it.. You can fix this by:

local value = script.Value.Value
 
script.Parent.Touched:Connect(function(hit)
if hit:FindFirstChild("Humanoid") then
	local humanoid = hit.Parent.Humanoid
		if value == false then
			value = true
			local fire  = Instance.new("Fire")
			fire.Enabled = true
			fire.Position = hit.Position
			fire.Heat = 5
			fire.Size = 10
			local function dmg()
				if value == true then
					humanoid.Health = humanoid.Health - 12.5
					wait(2)
				end
			end
		end
	end
end)

Hope this helps!

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