Humanoid is not a valid member of Tool

The title basically says it all

wait(3)

local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local toolEquipped = true
local character = script.Parent
local timeValue = game.ReplicatedStorage:WaitForChild("Timer")

function Format(Int)
	return string.format("%02i", Int)
end

function convertToHMS(Seconds)
	local Minutes = (Seconds - Seconds%60)/60
	Seconds = Seconds - Minutes*60
	return Format(Minutes)..":"..Format(Seconds)
end

tool.Equipped:Connect(function()
	character = tool.Parent
end)

timeValue.Changed:connect(function()
	local seconds = timeValue.Value
	if seconds > 15 then
		script.Parent.Frame.Screen.SurfaceGui.TimerText.Text = convertToHMS(seconds)
		script.Parent.Frame.Screen.SurfaceGui.TimerText.TextColor3  = Color3.fromRGB(255, 255, 255)
		toolEquipped = true
	else
		if toolEquipped then
			if character then
				if not character:FindFirstChildWhichIsA("Tool") then
					toolEquipped = false
					character.Humanoid:EquipTool(tool)
				end
			end
		end
	script.Parent.Frame.Screen.SurfaceGui.TimerText.Text = convertToHMS(seconds)
		script.Parent.Frame.Screen.SurfaceGui.TimerText.TextColor3 = Color3.fromRGB(255, 0, 0)
		tool.Handle.Tick:Play()
	end
	if seconds == 1 then
		wait(1)
		tool.Handle.Tick:Stop()
		tool.Handle.Beep:Play()
	end
end)
wait(3)

local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local toolEquipped = true
local character = script.Parent
local timeValue = game.ReplicatedStorage:WaitForChild("Timer")

function Format(Int)
	return string.format("%02i", Int)
end

function convertToHMS(Seconds)
	local Minutes = (Seconds - Seconds%60)/60
	Seconds = Seconds - Minutes*60
	return Format(Minutes)..":"..Format(Seconds)
end

tool.Equipped:Connect(function()
	character = tool.Parent
end)

timeValue.Changed:connect(function(player)
	local seconds = timeValue.Value
	if seconds > 15 then
		script.Parent.Frame.Screen.SurfaceGui.TimerText.Text = convertToHMS(seconds)
		script.Parent.Frame.Screen.SurfaceGui.TimerText.TextColor3  = Color3.fromRGB(255, 255, 255)
		toolEquipped = true
	else
		if toolEquipped then
			if character then
				if not character:FindFirstChildWhichIsA("Tool") then
					toolEquipped = false
					character.Humanoid:EquipTool(tool)
				end
			end
		end
	script.Parent.Frame.Screen.SurfaceGui.TimerText.Text = convertToHMS(seconds)
		script.Parent.Frame.Screen.SurfaceGui.TimerText.TextColor3 = Color3.fromRGB(255, 0, 0)
		tool.Handle.Tick:Play()
	end
	if seconds == 1 then
		wait(1)
		tool.Handle.Tick:Stop()
		tool.Handle.Beep:Play()
	end
end)

Try adding this:

toolEquipped = false
local humanoid = character:FindFirstChildOfClass("Humanoid")

	if humanoid then
		humanoid:EquipTool(tool)	
	end

Also are you doing this under a tool or?

5:24.628 Humanoid is not a valid member of Tool “Players.Tunnells.Backpack.Watch” - Server - this errors

did this work at all, or not @Tunnells ???

i might know what’s the issue. You made a variable local character = script.Parent, although you said local tool = script.Parent. So I think you should do local character = tool.Parent instead, or just leave it empty because you’ve already made a statement in a function.

local character = --- leave this empty

255,255,255 is not color @Tunnells

change this to

timeValue.Changed:connect(function(player)

I’d rather just leave this blank, so that your timeValue.Changed event doesn’t detect if there’s a character variable or not and it’ll only activate when the Tool gets Equipped

That won’t work, the Changed event returns back the New Value that it got changed into

--Say the new value changed is 5
workspace.NumberValue.Changed:Connect(function(NewValue)
    print(NewValue) --5
end)
1 Like

Right above this line

local character = script.Parent.Parent

Add this:
repeat wait() until script.Parent.Parent:IsA("Model)

That way the Character variable is only created once the player equips the tool.

03:43:35.383 Humanoid is not a valid member of Tool “Players.Tunnells.Backpack.Watch” - Server - WatchScript this doesnt work

Try doing this

local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local toolEquipped = true
local character
local timeValue = game.ReplicatedStorage:WaitForChild("Timer")

function Format(Int)
	return string.format("%02i", Int)
end

function convertToHMS(Seconds)
	local Minutes = (Seconds - Seconds%60)/60
	Seconds = Seconds - Minutes*60
	return Format(Minutes)..":"..Format(Seconds)
end

tool.Equipped:Connect(function()
	character = tool.Parent
end)

timeValue.Changed:connect(function()
	local seconds = timeValue.Value
	if seconds > 15 then
		script.Parent.Frame.Screen.SurfaceGui.TimerText.Text = convertToHMS(seconds)
		script.Parent.Frame.Screen.SurfaceGui.TimerText.TextColor3  = Color3.fromRGB(255, 255, 255)
		toolEquipped = true
	else
		if toolEquipped then
			if character then
				if not character:FindFirstChildWhichIsA("Tool") then
					toolEquipped = false
					character.Humanoid:EquipTool(tool)
				end
			end
		end
	script.Parent.Frame.Screen.SurfaceGui.TimerText.Text = convertToHMS(seconds)
		script.Parent.Frame.Screen.SurfaceGui.TimerText.TextColor3 = Color3.fromRGB(255, 0, 0)
		tool.Handle.Tick:Play()
	end
	if seconds == 1 then
		wait(1)
		tool.Handle.Tick:Stop()
		tool.Handle.Beep:Play()
	end
end)

Infinite yield possible on ‘Players.Tunnells.Backpack.Watch:WaitForChild(“Humanoid”)’ - Studio
also i want the tool to equip itself when its >15

Where exactly is that warning occurring? Also you could just reference the Character using tool.Parent.Parent, since by default it’ll be parented to the Player’s Backpack when you start the game

local tool = script.Parent
local handle = tool:WaitForChild("Handle")
local toolEquipped = true
local player = script.Parent.Parent
local character
local timeValue = game.ReplicatedStorage:WaitForChild("Timer")

function Format(Int)
	return string.format("%02i", Int)
end

function convertToHMS(Seconds)
	local Minutes = (Seconds - Seconds%60)/60
	Seconds = Seconds - Minutes*60
	return Format(Minutes)..":"..Format(Seconds)
end

tool.Equipped:Connect(function()
	character = tool.Parent
end)

tool.Unequipped:Connect(function()
    character = player.Character
end)

timeValue.Changed:connect(function()
	local seconds = timeValue.Value
	if seconds > 15 then
		script.Parent.Frame.Screen.SurfaceGui.TimerText.Text = convertToHMS(seconds)
		script.Parent.Frame.Screen.SurfaceGui.TimerText.TextColor3  = Color3.fromRGB(255, 255, 255)
		toolEquipped = true
	else
		if toolEquipped then
			if character then
				if not character:FindFirstChildWhichIsA("Tool") then
					toolEquipped = false
					character.Humanoid:EquipTool(tool)
				end
			end
		end
	script.Parent.Frame.Screen.SurfaceGui.TimerText.Text = convertToHMS(seconds)
		script.Parent.Frame.Screen.SurfaceGui.TimerText.TextColor3 = Color3.fromRGB(255, 0, 0)
		tool.Handle.Tick:Play()
	end
	if seconds == 1 then
		wait(1)
		tool.Handle.Tick:Stop()
		tool.Handle.Beep:Play()
	end
end)