Im trying to make it so that when a player sits in a seat, a animation is applied to them.
01 | local seat = script.Parent |
02 |
03 | function SeatIsSatIn(hit) |
04 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
05 | local character = hit.Parent |
06 | local humanoid = character.Humanoid |
07 | wait( 0.5 ) |
08 |
09 | if humanoid:GetState() = = Enum.HumanoidStateType.Seated then |
10 |
11 | local animation = Instance.new( "Animation" ) |
12 | animation.AnimationId = "http://www.roblox.com/asset/?id=182435998" |
13 |
14 | local track = humanoid:LoadAnimation(animation) |
15 | track:Play() |
I made this script a year ago when I was 8, it may not work, and it didnt..... Whats wrong with it. The script error finder on roblox didnt help me.
In Animations theres a thing called priorities. They are used to bypass or not bypass current animations. Use code below, We are going to be using action priority because its the recommended one for animations!
01 | local seat = script.Parent |
02 |
03 | function SeatIsSatIn(hit) |
04 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
05 | local character = hit.Parent |
06 | local humanoid = character.Humanoid |
07 | wait( 0.5 ) |
08 |
09 | if humanoid:GetState() = = Enum.HumanoidStateType.Seated then |
10 |
11 | local animation = Instance.new( "Animation" ) |
12 | animation.AnimationId = "http://www.roblox.com/asset/?id=182435998" |
13 | animation.Priority = Enum.AnimationPriority.Action |
14 |
15 | local track = humanoid:LoadAnimation(animation) |