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

My 'Click on GUI to play animation' script only works in studio and not in game. Any help?

Asked by 2 years ago

So I made a GUI that is supposed to play an animation upon being clicked on. I put a local script in every one of the Button Labels and wrote this script:

local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://8836638864"

local trackanimation = nil
local playability = true

function playAnimation (animationSource)
    if playability == true then
        local plr = game.Players.LocalPlayer
        trackanimation = plr.Character.Humanoid:LoadAnimation (animation)

        trackanimation.KeyframeReached:Connect(function()
            print("Animation Successfully Played") --I put this in to test if it worked and it did

        end)
        trackanimation:Play()
    end
end
script.Parent.MouseButton1Click:Connect(playAnimation)

The thing is, it works in Studio but doesn't work in-game and I have a feeling that it has something to do with FE but I have no idea how to fix it and I have searched online but it didn't really apply to this. I hope somebody can help me figure it out!

0
are you sure you own the animation? vendinY 5 — 2y
0
Yes I made it myself. My username is PoInareffe since I changed it last year. TheJacksterYT 19 — 2y
0
LoadAnimation is deprecated idk how that would relate to this issue tho TehEpixNeon 0 — 2y

Answer this question