Part-Animation | Help

Whenever you sit down in the seat the animation plays but only whenever it’s unanchored.

Script

local seat = script.Parent

function SeatIsSatIn(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local character = hit.Parent
local humanoid = character.Humanoid
wait(0.5)
if humanoid:GetState() == Enum.HumanoidStateType.Seated then
local animation = Instance.new(“Animation”)
animation.AnimationId = “http://www.roblox.com/asset/?id=4572683039
local track = humanoid:LoadAnimation(animation)
track:Play()

        local function StateChanged(oldState, newState)
            if newState ~= Enum.HumanoidStateType.Seated then
                track:Stop()
            end
        end

        humanoid.StateChanged:connect(StateChanged)
    end
end

end

seat.Touched:connect(SeatIsSatIn)

Any help is appreciated.

Reference the seat you want in a LocalScript in StarterCharacterScripts. Animations replicate to other clients, so you can load them on the client.

humanoid.Seated:Connect(function(isSeated, seat) 
	if isSeated then
		if seat then
			-- Play your sitting animation (make sure it is set to looping in anim editor)
		end
	else
		-- Stop your sitting animation
	end
end)

If you want your animation to play on all seats in your game, then you can simply change the default sitting animation to your sitting animation. More about that here: Using Animations | Documentation - Roblox Creator Hub

The animation works just not with anchored parts.

If the seat is unanchored, it will be ungrounded. This might be affecting the priority of the sitting animation depending on if or if it is not grounded. Is your animation priority set to action?

Again, you can simply change the default sitting animation so the game could not even load the wrong animation.

The seat works while it is un-anchored. I have no idea if my animation priority is set or not.

local seat = script.Parent

function SeatIsSatIn(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
local character = hit.Parent
local humanoid = character.Humanoid
wait(0.5)
if humanoid:GetState() == Enum.HumanoidStateType.Seated then
local animation = Instance.new(“Animation”)
animation.AnimationId = “http://www.roblox.com/asset/?id=4572683039
local track = humanoid:LoadAnimation(animation)
track:Play()

        local function StateChanged(oldState, newState)
            if newState ~= Enum.HumanoidStateType.Seated then
                track:Stop()
            end
        end

        humanoid.StateChanged:connect(StateChanged)
    end
end

end

seat.Touched:connect(SeatIsSatIn)

A seat connects a player to a seat by creating a weld, making the Part0 the seat. Welds make parts behave like they’re immovable by physics if one part or both is anchored, so if one part is anchored, the other is implicitly anchored

I don’t have anything else in mind, but you could manually play the animation, by getting the CFrames of the poses in the animation and then changing all of the motors’ / joints’ transform property

I can’t help if you don’t know what animation priority is. Consider reading articles on the developer hub about animations.