Sorry my english is pretty bad, i know the title is weird…maybe?
You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
Make a tool with Equip,Unequip,Acatived
What is the issue? Include screenshots / videos if possible!
when i play Acatived Animation,i cant playback unequip animation (sorry my english is pretty bad 8.57 MB file on MEGA
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
yes
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
local Player = game:GetService("Players")
script.Parent.Parent.Equipped:Connect(function()
local Character = script.Parent.Parent.Parent
local ani = Character.Humanoid:LoadAnimation(script.Parent.Equip)
ani:Play()
ani.Stopped:Connect(function()
ani:AdjustSpeed(0)
ani.TimePosition = ani.Length
end)
end)
script.Parent.Parent.Unequipped:Connect(function()
local Character = script.Parent.Parent.Parent.Parent.Character
local ani = Character.Humanoid:LoadAnimation(script.Parent.Equip)
ani:Play(0.100000001, 1, -1)
end)
script.Parent.Parent.Activated:Connect(function()
local Character = script.Parent.Parent.Parent
local ani = Character.Humanoid:LoadAnimation(script.Parent.Hit)
ani:Play()
ani.Stopped:Connect(function()
ani:AdjustSpeed(0)
ani.TimePosition = ani.Length
end)
end)
Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.
The error why the unequip animation wasn’t playing is cause of this line:
local Character = script.Parent.Parent.Parent.Parent.Character
-- The character is "script.Parent.Parent.Parent" like you writed in the two others functions.
Also, you really need to put a bit more efforts to better organize your code, here is it:
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Tool = script.Parent.Parent
local Humanoid = Character:FindFirstChild("Humanoid")
local EquipAnim = script.Parent:FindFirstChild("Equip")
local HitAnim = script.Parent:FindFirstChild("Hit")
if Humanoid ~= nil and EquipAnim ~= nil and HitAnim ~= nil then
Tool.Equipped:Connect(function()
local Track = Humanoid:LoadAnimation(EquipAnim)
Track.Priority = Enum.AnimationPriority.Action
Track:Play()
Track:AdjustSpeed(0)
Track.TimePosition = Track.Length
end)
Tool.Unequipped:Connect(function()
local Track = Humanoid:LoadAnimation(EquipAnim)
Track.Priority = Enum.AnimationPriority.Action
Track:Play()
end)
script.Parent.Parent.Activated:Connect(function()
local Track = Humanoid:LoadAnimation(HitAnim)
Track.Priority = Enum.AnimationPriority.Action
Track:Play()
Track:AdjustSpeed(0)
Track.TimePosition = Track.Length
end)
end
Yes it should be replicated to all other clients (players), in case if it is not replicated, you can create an “Animator” inside the Player Character in server side, then in client side, load animations on it instead of humanoid.
But while calling “Humanoid:LoadAnimation()”, it should automaticaly create an animator if there not already one so it’s fine.