Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

my idle animation will play but i cant get it to stop, how do i fix this?

Asked by 2 years ago
Edited 2 years ago

I have searched for a while and tried a couple solutions like creating a separate function.

the way my code works is the local script fires the server with a string, and then the server uses that string to decide which animation its gonna play (slash, idle, etc) here is my code

Server:

local rem = script.Parent:WaitForChild("RemoteEvent")

rem.OnServerEvent:Connect(function(player, stringe) 
    if stringe == "Idle" then
        local hum = player.Character.Humanoid
        local animator = hum.Animator
        local animation = game.ServerStorage.Animations.IdlePin

        local animationPlay = animator:LoadAnimation(animation)
        animationPlay:Play()
    elseif stringe == "IdleUnequip" then
        local hum = player.Character.Humanoid
        local animator = hum.Animator
        local animation = game.ServerStorage.Animations.IdlePin

        local track = animator:LoadAnimation(animation)
            track:Stop()
    end
end)

Local:

local equipped = false
local stringe
local rem = script.Parent:WaitForChild("RemoteEvent")

script.Parent.Equipped:Connect(function()
    stringe = "Idle"

    rem:FireServer(stringe)
    equipped = true
end)

script.Parent.Unequipped:Connect(function()
    stringe = "IdleUnequip"

    rem:FireServer(stringe)
    equipped = false
end)

1 answer

Log in to vote
0
Answered by 2 years ago

I found the answer

for anyone who wants to know the load animation had to be globalized

Ad

Answer this question