Hello, I am trying to make a seat and it won’t work the script.
Script:
Hello! I’ve changed your code a bit, because only one connection is necessary (an numbers of them matter if we care about performance). “anim” is a local variable, so it’s scope seems to be limited, thus problems with removed() function. Try the following code, and remove any existing animation instances, because script creates one for you.
In the future, please wrap your code between ```, because it’s readable that way and we can easily copy it.
seat = script.Parent
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://id_here"
local _animTrack
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
local occupant = seat.Occupant
if (occupant ~= nil) then
local animator = occupant:FindFirstChild("Animator")
if (animator) then
_animTrack = animator:LoadAnimation(anim)
_animTrack:Play()
end
else
_animTrack:Stop()
end
end)
EDIT (2021-03-07)
The above script does work, but you have to insert your own ID (that is also owned by you or your group), and represents the animation that has priority set to Action.
I named it animTrack because it is actually an animation track as a set of keyframes. It’s nothing but animation loaded on animator (better choice to load animations on in favor of loading directly on humanoid). Don’t let the sames confuse you. We are talking about something you can play and stop. It behaves like every other animation and sound track.
Your animation has to be a high priority animation. When you are creating this animation and exporting it, you have 4 priority choices (with core being the lowest and action being the highest). Low priority levels are easily overwritten by higher level ones. That’s why you should set priority to action: so it can overwrite the default sit animation.
Finally, try printing out random statements and see where the code stops working.
@TheKman2019 I don’t think there is anything more I can do. Animation does load on my side and it works. As long as humanoid rig type is correct (R15 animation for R15 rig type) and priority level is set to action, animation plays at all times.
not working still.
Anyway it can be like animation track?
@EssenceExplorer Not working. Had it at idle and action not working. Changed the animation ID to one of my other animations.