it does not work lol i think the issue isthe animation its self
but i dont know what the issue is
I think you can change the location of your animation to your script and do that :
local player = game:GetService("Players").LocalPlayer
local anims = script.Parent.Hold
local tool = script.Parent
local Animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script:WaitForChild("anims"))
tool.Equipped:Connect(function()
Animation:Play()
end)
tool.Unequipped:Connect(function()
Animation:Stop()
end)
I hope that was helpful !
it gave me errors the same line on the animation variable
It doesnt work at all it keep giving errors
Your animation might not be working for the following reasons:
- The animation ID is empty
- The game you’re working on does not own the animation (so the animation is not uploaded to your profile/group)
- The priority is low
- There’re no keyframes in the animation
There could be more reasons to why it’s not working, but make sure it is not these ^
To fix up some bad practice within your script, you should load the animation only once. Like this:
local player = game:GetService("Players").LocalPlayer
local anims = script.Parent.Hold
local loadedAnims
local tool = script.Parent
local Animator
tool.Equipped:Connect(function()
Animator = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
if not loadedAnims then -- Check if not loaded
loadedAnims = Animator:LoadAnimation(anims)
end
loadedAnims:Play()
end)
tool.Unequipped:Connect(function()
loadedAnims:Stop()
end)
Other than that you should probably set the AnimationPriority to see if that helps:
local player = game:GetService("Players").LocalPlayer
local anims = script.Parent.Hold
local loadedAnims
local tool = script.Parent
local Animator
tool.Equipped:Connect(function()
Animator = player.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
if not loadedAnims then -- Check if not loaded
loadedAnims = Animator:LoadAnimation(anims)
loadedAnims.Priority = Enum.AnimationPriority.Action
end
loadedAnims:Play()
end)
tool.Unequipped:Connect(function()
loadedAnims:Stop()
end)
Let me know if this helped!
sorry for the bad practice I havent coded in years and I got most of the code from some youtube vid
The script didnt change anything and the anim is none of what u listed
Could you please show me a screenshot of your explorer showing the Animation, script, tool, etc?
yes ofc, I just cant figure out how to screen shot on studio
heres what its supposed to look like
heres what it is
here is the explorer
here is the anims properties just in case
Oh I’ve forgotten something! You need to have the animation looped as well, that is why it’s not playing constantly probably…
So try doing loadedAnims.Looped = true after you load it
it still doesnt work at all nothing changed
maybe the anim over all doent work
but how do i fix that???
at this point i dont even know the issue
“If an Animator
is a descendant of a Humanoid or AnimationController in a Player’s Character
then animations started on that Player’s client will be replicated to the server and other clients.” Taken directly from the roblox API on animations
Try removing the default tool holding animation
alr how do i do that???
I have a place which overrides my default load animation, I made the animation which the tool connected to the right arm as a Motor6D. When The Equip runs I’d connect the M6D thru a remote event and Break the M6D when the tool gets unequipped,
The Server script could look something like this
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEventsFolder = ReplicatedStorage:WaitForChild("RemoteEvents")
local Init_M6D = RemoteEventsFolder:WaitForChild("Init_M6D")
local Destroy_M6D = RemoteEventsFolder:WaitForChild("Destroy_M6D")
local function Init(player)
local char = player.Character
local a = char:FindFirstChild("Right Arm"):WaitForChild("RightGrip")
local m6d = Instance.new("Motor6D")
m6d.Parent = char:FindFirstChild("Right Arm")
m6d.Name = "RightGrip"
m6d.Part0 = a.Part0
m6d.Part1 = a.Part1
m6d.C0 = a.C0
m6d.C1 = a.C1
a:Destroy()
return m6d
end
Init_M6D.OnServerInvoke = Init
Destroy_M6D.OnServerEvent:Connect(function(player, M6D)
M6D:Destroy()
end)
And the client could look somthing like this
--Init
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEventsFolder = ReplicatedStorage:WaitForChild("RemoteEvents")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Animator = Character:WaitForChild("Humanoid"):WaitForChild("Animator")
local Tool = script.Parent
local Equip_1 = script:WaitForChild("Equip_1")
local Equip_2 = script:WaitForChild("Equip_2")
local Slash_1 = script:WaitForChild("Slash_1")
Equip_1 = Animator:LoadAnimation(Equip_1)
Equip_2 = Animator:LoadAnimation(Equip_2)
Slash_1 = Animator:LoadAnimation(Slash_1)
local Init_M6D = RemoteEventsFolder:WaitForChild("Init_M6D")
local Destroy_M6D = RemoteEventsFolder:WaitForChild("Destroy_M6D")
local M6D
--Main?
Tool.Equipped:Connect(function(mouse)
M6D = Init_M6D:InvokeServer()
Equip_1:Play()
Equip_2:Play()
end)
Tool.Unequipped:Connect(function(mouse)
Equip_2:Stop()
Destroy_M6D:FireServer(M6D)
end)
Tool.Activated:Connect(function()
Slash_1:Play()
end)
If it still does not work, There might be something wrong with your animation, I suggest following this tutorial: How to animate tools (the easiest and best way) (for melees)
Also, to add on, The initialization (Init) of the M6D in the server script is connect thru a remote function, not to remote event. I’ve done this to return the specific M6D to destroy it later on.