Tool won't activate?

So i got this annoying bug that makes the tool won’t get activated unless im resetting it by re-equipping it

here is the part of the code :

char.ChildAdded:Connect(function(tool)
	if tool:IsA("Tool") and CS:HasTag(tool,"Potion") then
		tool.Activated:Connect(function()
			track:Play()
			wait(0.9)
			PoppingCap(tool)
			track.Stopped:Connect(function()
				wait(0.5)
				tool:Destroy()
			end)
		end)
	end
end)

[https://youtu.be/5DJSWviMMTE]
Here is the video, when im shaking its me trying to activate it

1 Like

Check the output, does it error whenever you can’t activate it? What does the error say?

it doesn’t output anything, there’s no error or anything

When does the tool not get activated?

Could you try adding these print lines like so, see what happens:

char.ChildAdded:Connect(function(tool)
	warn("CHILD ADDED: " .. tool:GetFullName())
	if tool:IsA("Tool") and CS:HasTag(tool,"Potion") then
		warn("passed through if statement, nice")
		
		tool.Activated:Connect(function()
			warn("hi ive been activated!!")
			
			track:Play()
			wait(0.9)
			PoppingCap(tool)
			track.Stopped:Connect(function()
				wait(0.5)
				tool:Destroy()
			end)
		end)
	end
end)

I’m just going to assume that the line line that destroys the tool after animation is intentional.

ah, the tool only passed through the if statement and the child added. but why is the tool can’t be activated tho?

Sorry…

Is this value on? Try configuring it a bit
image

1 Like

yes, i turn that on too. why is it matter?

Do you have an instance named “Handle” on your tool? RequiresHandle makes events like .Activated stop working if there isn’t a “Handle” on your tool.

Yes there is, but i kinda confused how the handle connects to the .Activated

It’s cause when the tool gets added, the tool has already activated before ChildAdded even registered it

hmm what do u think that caused it?

did you try to toggle it off brbdd

Could be a few different things.

Attempt 1
char.ChildAdded:Connect(function(tool)
	if tool:IsA("Tool") and CS:HasTag(tool, "Potion") then
		tool.Activated:Connect(function()
			track:Play()
			task.wait(0.9)
			PoppingCap(tool)
		end)
		track.Stopped:Once(function()
			task.wait(0.5)
			if tool.Parent then tool:Destroy() end
		end)
	end
end)
Attempt 2
char.ChildAdded:Connect(function(tool)
	if tool:IsA("Tool") and CS:HasTag(tool, "Potion") then
		tool.Activated:Connect(function()
			track:Play()
			task.wait(0.9)
			PoppingCap(tool)
		end)
		track.Ended:Once(function()
			task.wait(0.5)
			if tool.Parent then tool:Destroy() end
		end)
	end
end)
Attempt 3
char.ChildAdded:Connect(function(tool)
	if tool:IsA("Tool") and CS:HasTag(tool, "Potion") then
		local anim = track.Animation
		local newTrack = humanoid:LoadAnimation(anim)

		tool.Activated:Connect(function()
			newTrack:Play()
			task.wait(0.9)
			PoppingCap(tool)
		end)

		newTrack.Ended:Once(function()
			task.wait(0.5)
			if tool.Parent then tool:Destroy() end
		end)
	end
end)
local function OnChildAdded(tool)
	if not tool:IsA("Tool") or not CS:HasTag(tool, "Potion") then
		return
	end
	
	tool.Activated:Connect(function()
		track:Play()
		task.wait(0.9)
		PoppingCap(tool)
		
		track.Stopped:Once(function()
			task.wait(0.5)
			tool:Destroy()
		end)
	end)
end

char.ChildAdded:Connect(OnChildAdded)

for i,v in char:GetChildren() do
	OnChildAdded(v)
end
2 Likes

it seems that nothing works, i just let it be for now. thanks for the help tho

Hello! i am back and i found a solution.

			local ResultPotion = PotionModels:FindFirstChild(matchedRecipe.result)
			if ResultPotion then
				local result = ResultPotion:Clone()
				result.Parent = plr.Backpack
				local humanoid = plr.Character and plr.Character:FindFirstChildOfClass("Humanoid")
				if humanoid then
					humanoid:EquipTool(result)
				end
			end
			--[[ Before :
			result = ResultPotion:Clone()
			result.Parent = plr.Character
			]]

The problem is on a different script lol.
The thing is i realized that when the player gets the tool, the game couldn’t react fast enough to detect the humanoid :rofl: