#Why does it not work?

1 messages · Page 1 of 1 (latest)

sand stream
#
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

local idle = game:FindFirstChild("ReplicatedStorage").Animation.Combat:FindFirstChild("Idle")

local idleTrack = animator:LoadAnimation(idle)
idleTrack.Looped = true

script.Parent.Equipped:Connect(function()
    idleTrack:Play()
end)

script.Parent.Unequipped:Connect(function()
    if idleTrack.IsPlaying then
        idleTrack:Stop(0.2)
    end
end)
#

plis help

deft birch
#
local idle = game:FindFirstChild("ReplicatedStorage").Animation.Combat:FindFirstChild("Idle")

Could be the problem because if any of the chain is missing the whole experssion wil turn nil or fail

sand stream
#

there are no errors

deft birch
#
local idle = game.ReplicatedStorage:WaitForChild("Animation"):WaitForChild("Combat"):WaitForChild("Idle")

Is what i would recommend using

#

Alr

acoustic dagger
sand stream
#

still

deft birch
#

it was just an example

#

Btw just try to debug it
e.g. using prints
print(idle.AnimationId)

check from there

#

try to see where it goes wrong

acoustic dagger
#

Bud

#

Animation aint stopping or doesnt even play?

sand stream
#

it dosen't even play

#

@acoustic dagger

versed spire
#

bro..

#

just test animation

#

if that is working

acoustic dagger
deft birch
#

i would try to see if ur animation id actually exist lmao, when beginning i had that problem once

#

like with print("AnimationId:", idle.AnimationId)

#

Those small things could be the problem

sand stream
#

it exists

versed spire
#

I recommend to do just set looped to true

turbid monolithBOT
#

studio** You are now Level 11! **studio

versed spire
#

and start the animation continuously when u start the game

sand stream
#

man it dosen't work

deft birch
#

Like does you animatio nexist? if you equip it on a npc

#

Animation is such a pain

acoustic dagger
#

Im pretty sure that there is a crusial detail that detemines if animation works or not

#

Something that we dont know

deft birch
#

I always check if the Animator exists

sand stream
#

it works on a npc

deft birch
#

Is there another animation playing?

#

On that char

#

You can only have 1 Animator, if you have multiple Animators it wont work

#

Like per Humanoid

#
local animator = humanoid:FindFirstChildOfClass("Animator")
if not animator then
    animator = Instance.new("Animator")
    animator.Parent = humanoid
end

local idleAnim = ReplicatedStorage:WaitForChild("Animation"):WaitForChild("Combat"):WaitForChild("Idle")

local idleTrack = animator:LoadAnimation(idleAnim)
idleTrack.Looped = true
idleTrack.Priority = Enum.AnimationPriority.Action

script.Parent.Equipped:Connect(function()
    print("Tool equipped, playing idle animation")
    idleTrack:Play()
end)

-- Unequip handler
script.Parent.Unequipped:Connect(function()
    print("Tool unequipped, stopping idle animation")
    if idleTrack.IsPlaying then
        idleTrack:Stop(0.2)  
    end
end)

sand stream
deft birch
#

?

#

Yeah sure

acoustic dagger
#

Oh....

#

Wait

#

I have to check smth

acoustic dagger
deft birch
#

animator.AnimationId = "rbxassetid://YOUR_ANIMATION_ID"
local track = animator:LoadAnimation(animimator)

acoustic dagger
#

"Tool Equipped"?

deft birch
#

Im helping blind

#

I do not know what is happening to your studio

acoustic dagger
#

I was talking to @sand stream

sand stream
#

print("Tool equipped, playing idle animation")

#

this part dosen't print

acoustic dagger
#

Well

#

As i thought

#

Does your tool have a part called "Handle" if not, then there is your cause of it

#

Bascially tool requires a handle, without it it wont work. To change it just turn this option off in tool properties

#

If u have turned on "RequiresHandle" any signal won't work unless u don't parent a handle to it

sand stream
#

ok so

#

now it does print

#

but

#

it dosen't play the anim

acoustic dagger
#

BROOO

#

Set priority to Idle, not action

sand stream
#

did it alr

#

and still

#

i tried simplifing it, being more specific, changing the avatar settings

#

but still

acoustic dagger
#

...

#

Is your script a Localscript or normal script?

sand stream
#

ok so

#

on npc works

#

BUT

#

on player dosen't

acoustic dagger
#

Im asking if its a LocalScript

#

On your tool

sand stream
#

yes

acoustic dagger
#

The blue one is a localscript and grey on is a script

#

U have the blue one?

sand stream
#

yes

acoustic dagger
#

For me it works

#

Dunno bro

sand stream
#

i hate roblox

#

it changed the avatar setting

#

and i found the settings

#

that makes the anim work on a certain rig

#

also tysm for helping

#

@acoustic dagger