a = script.Parent.Parent.Parent:FindFirstChild(Head) function a1() a:Delete() end script.Parent.Parent.Activated:Connect(a1)
Whenever I use the tool i get the error "Argument 1 missing or nil"
It's a tool, It's supposed to remove your head when you use it
Thanks ;P
Normally you should tell us not only the error, but what line it occurred on.
metalicurt is correct, you need to have Head
in quotes.
However, the script will run before the Tool is parented to the player's character. You should get the head only when the tool is activated or equipped (unless you use game.Players.LocalPlayer.Character
)
Also, remember to use descriptive variable names (this is more important in larger scripts). A fixed script:
local tool = script.Parent.Parent function RemoveHead() local head = tool.Parent:FindFirstChild("Head") if head then head:Destroy() end end tool.Activated:Connect(RemoveHead)
Note that it checks for the head each time it is activated and won't error if the head isn't there (ex. because the script ran already).
Wouldn't you want the FindFirstChild argument to be a string? as in FindFirstChild("Head")
I am still learning so I may be wrong.