:IsA("Tool") check always turns out false. Help?

I need to find the tool, not the character.

local Used = script.Parent.Used.Value

script.Parent.Touched:Connect(function(hit)
print(hit.Parent.ClassName)
if hit.Parent:FindFirstAncestorOfClass(“Tool”) then
local CTool = hit.Parent:FindFirstAncestorOfClass(“Tool”)
if Used == false then
Used = true
for i = 5,1,-0.5 do
~~ local PBSpeed = (tostring(math.ceil(math.random(0,1))) … “.” … tostring(math.ceil(math.random(5,9))))
~~ script.Parent.Knife.PlaybackSpeed = tonumber(PBSpeed)

~~ script.Parent.Knife:Play()~~
~~ script.Parent.NameTag.Frame.WaitTime.Text = tostring(math.ceil(i)) … " seconds remaining."
~~ wait(0.5)

~~ end
~~ CTool:FindFirstChild(“Sliced”).Value = true

CTool.Name = “Sliced” … CTool.Name
end
end
~~end)

I edited the script a little, but it still did not work.
This is so weird. It starts to turn me mad ngl.

This is a script that would actually make sense (I hope)

local Used = script.Parent.Used.Value

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local hits = hit.Parent:GetChildren()
		for i = 1, #hits do
			if hits.ClassName == "Tool" then
				print("ToolDetected")
			end
		end
	end
end)

I tried already, it did nothing.
:confused:

Oops I’m a complete dumbo.
Let me edit that script.
Already mentioned I’m tired.

So, I managed to fix it on my own. This is the script I now use, if anyone else ever finds this topic from a google search with a similar issue…

script.Parent.Touched:Connect(function(hit)
	if hit:FindFirstAncestorOfClass("Tool") then
		print("Tool found")
	end
end)
1 Like