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
Change tool.child into child in line 12