New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

Specific sitting animation for certain seat (like on vibe train)?

Asked by 10 days ago

tryna make a seat in where u sit on it and it plays a certain sitting animation. like on the game vibe train. but the script aint working. take a look pls

local Seat = script.Parent
local Animation = script:WaitForChild("Animation")
Seat.Changed:connect(function() --You can get the individual property changed event, but this is simpler.
     if Seat.Occupant ~= nil then
          local Track = Seat.Occupant.Humanoid:LoadAnimation(Animation) --Load the animation
          Track:Play() --Play the animation
          Seat.Occupant.Humanoid.Jumped:wait() --Wait for player to leave the seat
          Track:Stop() --Stop the animation
     end
end)

pls help

0
print something in your changed event to see if it is running royaltoe 4557 — 10d
0
there's a way simpler way, give me a sec s_iara 94 — 10d

1 answer

Log in to vote
0
Answered by
s_iara 94
10 days ago

Make sure you have your animation id ready

local sitAnims = {0, 0} --Paste the same one in twice, unless you want random ones

local seat = script.Parent --Link this to the seat
local playingAnim 

local newAnim = Instance.new('Animation')
newAnim.AnimationId = 'rbxassetid://'..sitAnims[math.random(#sitAnims)]

seat.Changed:Connect(function(property)
    if property == 'Occupant' then
        local occupant = seat.Occupant
        if not occupant then if playingAnim then playingAnim:Stop() return end end
        playingAnim = occupant:LoadAnimation(newAnim)
        playingAnim:Play()
    end
end)

If this works make sure to accept it, if you have any questions I'll try to be active enough to help!

Ad

Answer this question