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

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

Asked by 5 years 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

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

pls help

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

1 answer

Log in to vote
0
Answered by
s_iara 94
5 years ago

Make sure you have your animation id ready

01local sitAnims = {0, 0} --Paste the same one in twice, unless you want random ones
02 
03local seat = script.Parent --Link this to the seat
04local playingAnim
05 
06local newAnim = Instance.new('Animation')
07newAnim.AnimationId = 'rbxassetid://'..sitAnims[math.random(#sitAnims)]
08 
09seat.Changed:Connect(function(property)
10    if property == 'Occupant' then
11        local occupant = seat.Occupant
12        if not occupant then if playingAnim then playingAnim:Stop() return end end
13        playingAnim = occupant:LoadAnimation(newAnim)
14        playingAnim:Play()
15    end
16end)

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

0
When i use this script, the animation plays like for a milisecond and it returns back to a normal sitting animation. Do i have to change something? I have set custom animation id. DJ_cebula 0 — 5y
0
The script does not work for me at all. Bxrista 0 — 5y
0
Dj, the exact opposite for me happens. For a millisecond it has a normal seat but then goes to the orginal. I forgot how I've put my animation. Make sure the script isn't local and the parent is the seat, not model. Also, make sure your animation is looped, which is probably why that's happening. s_iara 94 — 5y
0
Bxrista, make sure you do all of the steps I just listed and if it still doesn't work, dm me. I'll be happy to help :) s_iara 94 — 5y
View all comments (3 more)
0
Hey s_iara, the script works now, but I am having the same problem as DJ_cebula. The animation is looped and the parent is the seat. Can you please message me @Bxrista#4009 to help me? Thanks. Bxrista 0 — 5y
0
I also need help, as I am having the same problems as Bxrista. PigsLayEggs 0 — 5y
0
I was able to fix the problem by removing the default sitting animation. HonestlyPotato 0 — 5y
Ad

Answer this question