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

Im not sure why this sitting animation to a seat wont work?

Asked by 5 years ago

Im trying to make it so that when a player sits in a seat, a animation is applied to them.

01local seat = script.Parent
02 
03function 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()
View all 28 lines...

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.

1 answer

Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
5 years ago

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!

01local seat = script.Parent
02 
03function 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)
View all 29 lines...
0
It worked great, i had to alter it a bit though. fireyfoxninja21 9 — 5y
Ad

Answer this question