You are trying to find the humanoid in the player instead of the character
-- code for animations and stuff
local plr = -- YourPlayer Here
function unEquipped()
local drink = plr.Character:FindFirstChild("Humanoid"):LoadAnimation(Tool.drink)
drink:Stop()
local equip = plr.Character:FindFirstChild("Humanoid"):LoadAnimation(Tool.equip)
equip:Stop()
end
script.Parent.Unequipped:Connect(unEquipped)
Ah, I will try to fix it.
Edit: it didn’t work, but the bug is removed.
cuz you’re not playing the animation, add :Play()
Why would I have to play the animation when I want it to stop?
oh yeah you want it to stop, can you show us your updated code?
local plr = script.Parent.Parent.Parent
function unEquipped()
local plr = script.Parent.Parent.Parent
local drink = plr.Character:FindFirstChild("Humanoid"):LoadAnimation(Tool.drink)
drink:Stop()
local equip = plr.Character:FindFirstChild("Humanoid"):LoadAnimation(Tool.equip)
equip:Stop()
end
script.Parent.Unequipped:Connect(unEquipped)
Might be because you’re loading a new animation (despite it being the same animation) onto the humanoid. Take the original saved animation and use :Stop() on that instead
ru sure that script.Parent.Parent.Parent is the player?
if the localscript is located in StarterPlayerScripts the player will be script.Parent
i believe he’s playing it OnEquipped()
It is a script inside of a Bloxy Cola.
Summary
This text will be hidden
then the character will be script.Parent.Parent
function unEquipped()
local char = script.Parent.Parent
local drink = char:FindFirstChild("Humanoid"):LoadAnimation(Tool.drink)
drink:Stop()
local equip = char:FindFirstChild("Humanoid"):LoadAnimation(Tool.equip)
equip:Stop()
end
script.Parent.Unequipped:Connect(unEquipped)
So then what should I do?
Summary
This text will be hidden
Load the animation outside of any equipped & unequipped events, then when the tool is equipped do :Play() and when it is unequipped do :Stop()
I have an idea, instead of putting it in the function, I will put It as a variable
It completely breaks the script and the animation never even ends up playing. I will try to add .character
nvm, it doesn’t make sense since you’re loading the anim & stopping it
Should I just show you all the entire script?
local Tool = script.Parent;
local plr = script.Parent.Parent.Parent
local opened = script.Parent.opened
local drink = plr.Character:FindFirstChild("Humanoid"):LoadAnimation(Tool.drink)
local equip = plr.Character:FindFirstChild("Humanoid"):LoadAnimation(Tool.equip)
enabled = true
function onActivated()
if not enabled then
return
end
if opened.Value == true then
enabled = false
Tool.Handle.DrinkSound:Play()
drink:Play()
task.wait(5)
enabled = true
end
end
enabled = true
function onEquipped()
if opened.Value == false then
equip:Play()
Tool.Handle.OpenSound:Play()
task.wait(1)
opened.Value = true
end
end
function unEquipped()
local plr = script.Parent.Parent.Parent
drink:Stop()
equip:Stop()
end
script.Parent.Activated:Connect(onActivated)
script.Parent.Equipped:Connect(onEquipped)
script.Parent.Unequipped:Connect(unEquipped)
Can you give a different example because it would make more sense since I gave you the full script