Hi, I’ve recently made a few weapons for a game I plan on making for experience, all them I animated, modelled and scripted myself. (scripted from a tutorial) But I experience one of the tools sometimes not using the animation when I equip it.
What I don’t want ^^^
What I do want ^^^
Sometimes it does work but I want it to constantly work for fluidity inside the game so everything is smooth.
It doesn’t do this for any other tool, the axe idle uses the exact same ID as another tool yet the other tool always fluently uses the idle like all others except the axe.
I’ve changed animation priority but that just interfered with other animations ingame
I’m also confused. Do you want the animation playing or not? The thread’s title and content seem to disagree with what you do and don’t want as indicated by the pictures.
It would also help if you showed the hierarchy of your tools and any code related to idle animations to better understand the problem. Can’t discern anything off of the information provided so far other than an oversight on your part that needs to be fixed.
Sorry I thought it made sense aha, sometimes when the tool is equipped the idle shown in the first picture is what happens, yet this is not what I want, I want the idle animation shown in the second to play
Here is the code inside the tool.
local tool = script.Parent
local idleAnim = script:WaitForChild("Idle")
local idleAnimTrack
local swingAnim = script:WaitForChild("Swing")
local swingAnimTrack
local slashSound = script:WaitForChild("SlashSound")
local sheathSound = script:WaitForChild("SheathSound")
local hitSound = script:WaitForChild("HitSound")
local hitCharacters = {}
local debounce = false
tool.Equipped:Connect(function()
local humanoid = script.Parent.Parent.Humanoid
if not idleAnimTrack then idleAnimTrack = humanoid:LoadAnimation(idleAnim) end
idleAnimTrack:Play()
sheathSound:Play()
end)
tool.Unequipped:Connect(function()
if idleAnimTrack then idleAnimTrack:Stop() end
if swingAnimTrack then swingAnimTrack:Stop() end
sheathSound:Play()
end)
tool.Activated:Connect(function()
if debounce then return end
debounce = true
local humanoid = script.Parent.Parent.Humanoid
if not swingAnimTrack then swingAnimTrack = humanoid:LoadAnimation(swingAnim) end
swingAnimTrack:Play()
wait(0.1)
slashSound:Play()
wait(0.5)
debounce = false
end)
tool.Blade.Touched:Connect(function(touch)
if hitCharacters[touch.Parent] or not debounce then return end
if touch.Parent:FindFirstChild("Humanoid") then
if touch.Name == "Head" then
touch.Parent.Humanoid:TakeDamage(25)
else
touch.Parent.Humanoid:TakeDamage(10)
end
hitSound:Play()
hitCharacters[touch.Parent] = true
wait(1)
hitCharacters[touch.Parent] = nil
end
Oh, no I see it now. I can see that the second picture has a distinct holding animation. I thought you didn’t have any idle animation and you were just looking to stop the default idle from playing.
The toolnone animation has either the Core or Idle priority, so Movement or Action would be needed to hard-overwrite the default holding animation. I’m not sure what your animation’s priority is. Code wise, it doesn’t look like you’re doing anything wrong here though - this is exactly how it should be set up.
In this case, my simplest recommendation would be to stop the animation when it plays. Assuming you’re handling this all from a server script, you’ll need to check the AnimationId for the toolnone animation and stop it if your specific tool is equipped. This will avoid editing the Animate script itself or changing your priorities, since they’d supposedly interfere with other animations.
You can add these parts to your code as an example of how to work around this problem:
-- With your other variables
local animationPlayed
-- Anywhere in your script
local function connectAnimationPlayed(humanoid)
if animationPlayed then return end
animationPlayed = humanoid.AnimationPlayed:Connect(function (animationTrack)
if string.find(animationTrack.Animation.AnimationId, "0", 1, true) then
animationTrack:Stop()
end
end)
end
-- Anywhere in your script
local function disconnectAnimationPlayed()
if not animationPlayed then return end
animationPlayed:Disconnect()
animationPlayed = nil
end
-- In your equip function:
connectAnimationPlayed(humanoid)
-- In your unequip function:
disconnectAnimationPlayed()