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)
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.
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
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