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

"child is not a valid member of tool". What does that mean in this case?

I tried to make it so that when you press q, a part called "Blade" will get a ParticleEmitter and it works the first time you press q, but the second time the output reads:"Child is not a valid member of tool".

local plr = game.Players.LocalPlayer.Character
local UIS = game:GetService("UserInputService")

UIS.InputBegan:connect(function(inputObject, gameProcessed)
	if inputObject.KeyCode == Enum.KeyCode.Q and beserk.Value.Value == true then
		game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("beserk").Value = true
-- this is where the problem assumingly is --
		for i, tool in pairs(plr:getChildren()) do
			if tool:IsA('Tool') then
				for i, child in pairs(tool:getChildren()) do
					if child.Name == "Blade" then
						game.ReplicatedStorage.BeserkParticle:Clone().Parent = tool.child
					end
				end
			end
		end
---------------------------------------------------------------
		wait(10)
			for i, tool in pairs(plr:getChildren()) do
			if tool:IsA('Tool') then
				for i, child in pairs(tool:getChildren()) do
					if child.Name == "Blade" then
						for i, particle in pairs(child:getChildren()) do
							if particle:IsA('ParticleEmitter') then
								particle:Remove()
							end
						end
					end
				end
			end
		end
		game.Players.LocalPlayer:WaitForChild("PlayerGui"):WaitForChild("beserk").Value = false
		end
		end)

1 comment

0

Change tool.child into child in line 12

1 answer

✓ Accepted answer

On line 12, you're setting something to parent to tool.child. There's no guarantee that every tool added to the player will have a child called 'child', you're probably meaning to use tool.Blade, or just 'child' instead of tool.child

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