My animations won't load, and the output is saying weird things

I am making a ‘Fortnite Dancing Game (hold the cringe)’ and I have uploaded the animations, and I have made the script to play them. Some animations are only allowed to be used if the user has purchased a game pass. In ROBLOX Studio, the animations play when I click the buttons, and the game-pass only animations function properly. However, when I go in the game, it says that I do not own the game pass (which I do), and none of the animations will load. I checked the output, and it says that I was trying to instantiate an integer.

Code
player = game.Players.LocalPlayer

animationdab = script.Parent.Background.Dab:WaitForChild("Animation")
animationdd = script.Parent.Background.DefDance:WaitForChild("Animation")
animationfloss = script.Parent.Background.Floss:WaitForChild("Animation")
animationhype = script.Parent.Background.Hype:WaitForChild("Animation")
animationinfdab = script.Parent.Background.InfDab:WaitForChild("Animation")
animationOJ = script.Parent.Background.OJ:WaitForChild("Animation")
animationtakel = script.Parent.Background.TakeL:WaitForChild("Animation")
animationworm = script.Parent.Background.Worm:WaitForChild("Animation")

DabButton = script.Parent.Background.Dab
DefaultButton = script.Parent.Background.DefDance
FlossButton = script.Parent.Background.Floss
HypeButton = script.Parent.Background.Hype
InfDabButton = script.Parent.Background.InfDab
OJButton = script.Parent.Background.OJ
TakeLButton = script.Parent.Background.TakeL
WormButton = script.Parent.Background.Worm
OpenButton = script.Parent.DancesOpen
BackButton = script.Parent.Background.Back
Background = script.Parent.Background

enableddab = true
enableddefault = true
enabledfloss = true
enabledhype = true
enabledinfdab = true
enabledoj = true
enabledtakel = true
enabledworm = true

--[[
    Animation Times:

    Dab: 0.9
    Default: 4.5
    Floss: 3.2
    Hype: 3.5
    Infinite Dab: 1.8
    Orange Justice: 6.2
    Take the L: 1.4
    Worm: 2
--]]

OpenButton.Activated:Connect(function()
    if Background.Visible == true then
        Background.Visible = false
    else
        Background.Visible = true
    end
end)



BackButton.Activated:Connect(function()
    Background.Visible = false
end)

--[[

--]]

-- Dab -- 

DabButton.Activated:Connect(function()
    if enableddab then
        enableddab = false

        local animationtrack1 = player.Character.Humanoid:LoadAnimation(animationdab)
        animationtrack1:Play()

        wait(0.9)
        enableddab = true
        animationtrack1:Stop()
    end
end)

-- Default -- 

DefaultButton.Activated:Connect(function()
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId, 6501778) then
        if enableddefault then
            enableddefault = false

            local animationtrack2 = player.Character.Humanoid:LoadAnimation(animationdd)
            animationtrack2:Play()

            wait(4.5)
            enableddefault = true
            animationtrack2:Stop()
        else
            DefaultButton.TextLabel.Text = "You don't own the pass!"
            wait(3)
            DefaultButton.TextLabel.Text = "Default Dance ????"
        end
    end 
end)

-- Floss -- 

FlossButton.Activated:Connect(function()
    if enabledfloss then
        enabledfloss = false

        local animationtrack3 = player.Character.Humanoid:LoadAnimation(animationfloss)
        animationtrack3:Play()

        wait(3.2)
        enabledfloss = true
        animationtrack3:Stop()
    end
end)

-- Hype -- 

HypeButton.Activated:Connect(function()
    if enabledhype then
        enabledhype = false

        local animationtrack4 = player.Character.Humanoid:LoadAnimation(animationhype)
        animationtrack4:Play()

        wait(3.5)
        enabledhype = true
        animationtrack4:Stop()
    end
end)

-- Infinite Dab --

InfDabButton.Activated:Connect(function()
    if enabledinfdab then
        enabledinfdab = false

        local animationtrack5 = player.Character.Humanoid:LoadAnimation(animationinfdab)
        animationtrack5:Play()

        wait(1.8)
        enabledinfdab = true
        animationtrack5:Stop()
    end
end)

-- Orange Justice --

OJButton.Activated:Connect(function()
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player, 6501781) then
        if enabledoj then
            enabledoj = false

            local animationtrack6 = player.Character.Humanoid:LoadAnimation(animationOJ)
            animationtrack6:Play()

            wait(6.2)
            enabledoj = true
            animationtrack6:Stop()
        else
            OJButton.TextLabel.Text = "You don't own the pass!"
            wait(3)
            OJButton.TextLabel.Text = "Orange Justice ????"
        end
    end 
end)

-- Take the L -- 

TakeLButton.Activated:Connect(function()
    if enabledtakel then
        enabledtakel = false

        local animationtrack7 = player.Character.Humanoid:LoadAnimation(animationtakel)
        animationtrack7:Play()

        wait(1.4)

        enabledtakel = true
        animationtrack7:Stop()
    end
end)

-- Worm -- 

WormButton.Activated:Connect(function()
    if enabledworm then
        enabledworm = false

        local animationtrack8 = player.Character.Humanoid:LoadAnimation(animationworm)
        animationtrack8:Play()

        wait(2)

        enabledworm = true
        animationtrack8:Stop()
    end
end)

image

4 Likes

I’ve seen somewhere that MarketPlaceService:UserOwnsGamePassAsync takes a player’s user id as its first argument.

if game:GetService("MarketPlaceService"):UserOwnsGamePassAsync(player.UserId,--[[gamepassid here]]) then

As for the animations, I don’t really have anything to say except that you should make sure they are uploaded to Roblox, or their AnimationId takes the appearance of a ContentId, which starts with rbxassetid:// or something like roblox.com/asset/?id=. At one time, animations were able to just be uploaded locally and not directly to Roblox, probably not anymore though.

1 Like

player.UserId not player

-- Orange Justice --

OJButton.Activated:Connect(function()
    if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player, 6501781) then

That line sends player as the argument, which is an Instance. It should send (as you do on an earlier line) player.UserID which is of type Int64.

Post title should be “Unable to cast Instance to int64” because that’s the error you’re getting, because that’s the problem. Has nothing to do with animations. If anything, it has to do with MarketPlaceService, as you describe in the body of your post.

Posting the error message is helpful in resolving the issue. Posting the line number which is shown just after the error message in the output would be even more helpful to you and to responders.

… And I’m happy to be corrected on whatever I post too. Hope this helps.

I caught my mistake, and I fixed it, but it still says that it was trying to instantiate a value.

Never mind, it works now, but I am still having the issue of the animations not loading.

it says that I do not own the game pass (which I do)

Does it still say you don’t own the game pass?

No, now the game pass part is fixed.

Once there is no more issue with the Game Pass, then we’re finally able to ask about the Animations.

https://developer.roblox.com/api-reference/function/Humanoid/LoadAnimation

Is your code above running in a LocalScript on the Player Client?

What happens when you create an additional new temporary button that runs a copy of the same script with all the game pass and any other conditions removed in order to just test loading animations alone with no other logic involved?

It still doesn’t work. I checked my code, and it matches.