Tool won't work

Hello, scripting rookie here!

function bigBRAIN(head)
	local boy = head.Parent:FindFirstChild("Humanoid")
	if (boy ~= false) then
		boy.Health = 0
	end
end

script.Parent.Activated:Connect(bigBRAIN)
Error showing up

Screenshot%20(305)

So I tried making a tool for a player that’ll kill them if they use it, but nothing seems to be happening. Any help?

The Activated signal/event doesn’t pass anything to connected functions; ergo head is equal to nil (it isn’t bound to anything).

2 Likes

OH, so that’s why. Thank you for the help!

1 Like

Try this:

local Tool = script.Parent
local Players = game:GetService('Players')

function bigBRAIN()
	local Player = Players:GetPlayerFromCharacter(Tool.Parent)
	if Player then
		local Character = Player.Character or Player.CharacterAdded:Wait()
		Character:BreakJoints()
	end
end

Tool.Activated:Connect(bigBRAIN)
1 Like