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

How to make player play custom animation when sitting in seat?

Asked by
ka3r 14
5 years ago

How do I make it so that when the player sit in a seat it plays a custom animation rather than the default ROBLOX sitting animation?

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago
01-- Server Script
02 
03local Players = game:GetService("Players") -- Our player service to use the PlayerAdded & CharacterAdded events.
04local SitAnimID = 507776043 -- Set to your specified animation id to replace the default sit idle animation.
05 
06Players.PlayerAdded:Connect(function(Player) -- On player added
07    Player.CharacterAdded:Connect(function(Character) -- When character is added
08    local Animation = Character:FindFirstChild('SitAnim', true) -- Finding the sit animation in the character
09    Animation.AnimationId = ('rbxassetid://%s'):format(SitAnimID) -- Replacing animation id with yours.
10    end)
11end)

Hope this has helped, please learn from this and have a good day. If you have anything else you want to add on you can ask me. :)

Requested Script (Ignore)

01-- Server Script
02 
03local Players = game:GetService("Players") -- Our player service to use the PlayerAdded & CharacterAdded events.
04local SitIdleAnim = 507776043 -- Set to your specified animation id to replace the default sit animation.
05 
06local Seats = {
07[workspace.Seat1] = 507770818;
08[workspace.Seat2] = 507770677;
09}
10-- For each seat as the key, the value will the animation you want to play
11 
12Players.PlayerAdded:Connect(function(Player) -- On player added
13    Player.CharacterAdded:Connect(function(Character) -- When character is added
14    local Animation = Character:FindFirstChild('SitAnim', true) -- Finding the sit animation in the character
15    local Humanoid = Character.Humanoid -- So we can use the GetPropertyChangedSignal
View all 26 lines...
0
Thanks! However, do you know how to make it play an animation when the player is only sitting on a specific seat? Like for example seat1 will be used as a bed, so I use your code to play the sleeping animation on it. However, I'll be using seat2 as a chair, but when I sit on it, it plays the bed animation for seat1. How do I make seat2 have it's own animation? I hope you can understand and help me ka3r 14 — 5y
0
Sure, i've done it. Check the script i've added below 'Requested Script (Ignore)' User#31525 30 — 5y
0
Hello, trying to have multiple copies of "Seat1". To make things easier I'll reference the original seat1 as "st1" and the cloned as "st1jr" The properties of both "st1" and "st1jr" are the same (I just used Ctrl+D), when sitting on "st1" the correct sitting animation plays. However, sitting on "st1jr" causes the "SitIdleAnim" to play. How do I make it so all s1 in the server plays the same ani? ka3r 14 — 5y
0
Sorry for the late comment. I've noticed that the script is having trouble finding "seat1" when it's inside a model. Instead of having to do "game.Workspace.Model.Model.Seat1" which will then have to be changed everytime the parent of Seat1 is changed, is there a way to find seat1 regardless of it's parent? Thanks in advance. ka3r 14 — 5y
Ad

Answer this question