Animation work fine. But its not what i want

Hello Developers .

So i want players make exactly animation like this

but the issues is when i replace the animation to seat animation it like this

here the code:

local sitAnims = {4933721123, 4933721123}

local seat = script.Parent 
local playingAnim
 
local newAnim = Instance.new('Animation')
newAnim.AnimationId = 'rbxassetid://'..sitAnims[math.random(#sitAnims)]
 
seat.Changed:Connect(function(property)
    if property == 'Occupant' then print("stop")
        local occupant = seat.Occupant
        if not occupant then if playingAnim then playingAnim:Stop() return end end print("run")
        playingAnim = occupant:LoadAnimation(newAnim)
        playingAnim:Play()
    end
end) 

**

1 Like

Maybe I’m wrong but I believe math.random requires 2 arguments. Maybe try having math.random(1,#sitAnims)

1 Like

math.random does indeed need two arguments.

random can be called with a single argument, and it’ll return an int in the range (1, x).

I think he’s referring to how he can override or replace the default Roblox seat animation with his.

@nhannguyen5078

You could try calling :GetPlayingAnimationTracks() on the player’s humanoid to stop every playing track when they sit in the chair, and then for your animation, set it’s priority to the highest, ‘Action’ I think it is.

Sorry answer wrong player. :disappointed_relieved:

In the math.random try to add one more argument because math.random require 2 argument inside, and don’t forget when you local a sitAnims, add a GetChildren() function in so the math.random can know what it will random. The argument should be 1, the code of the math.random should be like this :
newAnim.AnimationId = 'rbxassetid://'..sitAnims[math.random(1, #sitAnims)]
Hope this can help you out!

P/S : Are you Vietnamese? ( Sorry for asking this stupid question. )

@OriginalDevelops yeah i’m understand now. didn’t know it.

P/S :Yes i am