Recently I have been working on Train related projects, one of the things I tried was a different seat animation for trains where you need to stand while driving
my question is how would i make this animation appear but only in the driver seat, the only other topics related to this was replacing it, but it would look odd having people standing on seats inside the train
2 Likes
You could upload the animation, then detect whenever the seat has someone sitting in it (Seat.Occupant).
You can then do something like this, after parenting the Animation to the script:
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)
edit: haven’t tested it so it might not work. Be sure to set the Seat variable to wherever your seat is located.
edit #2: just added that in. Be sure to just put the script into the seat and add the animation object into the script.
6 Likes
If you wanted a way of positioning a character, and not specifically playing an animation, you could cframe the character to be in a certain way.
1 Like
Create whatever animation you would want to play then load the animation instance into the player character humanoid and play it whenever humanoud.Sit = true and and stop it whenever it is false.
If you find yourself needing to move the player up due to the animation you can simply use CFrame to move the player up.
2 Likes
Just rename the seat that is used for driving to something like DriverSeat and then when the player sits, check if it’s the driver seat and play the animation.
Thanks to all those who tried to help, I ended up editing the default roblox animation script and mixing a few of these ideas into it.
2 Likes