Sitting Animations- different for every seat

I’ve been trying to figure out how I can put my sitting animations that I made and override the default animation. I tried ILurd’s script and it didn’t work. What could I fix?

local seat = script.Parent --Link this to the seat
local playingAnim 

local newAnim = Instance.new('Animation')
newAnim.AnimationId = 'rbxassetid://'..sitAnim

seat.Changed:Connect(function(property)
    if property == 'Occupant' then
        local occupant = seat.Occupant
        if not occupant then if playingAnim then playingAnim:Stop() return end end
        playingAnim = occupant:LoadAnimation(newAnim)
        playingAnim:Play()
    end
end)
1 Like

Have you tried adding an animation to the seat itself?

Do I set it on loop too like usual in the animation editor.

So I changed the script, set the animation priority to action, set it on loop too and it didn’t work. I don’t understand what’s wrong should the script be looking like this?

local seat = script.Parent --Link this to the seat
local playingAnim 

local newAnim = Instance.new('Animation')
newAnim.AnimationId = 'rbxassetid://'..sitAnim

seat:GetPropertyChangedSignal("Occupant"):Connect(function(property)
    if property == 'Occupant' then
        local occupant = seat.Occupant
        if not occupant then if playingAnim then playingAnim:Stop() return end end
        playingAnim = occupant:LoadAnimation(newAnim)
        playingAnim:Play()
    end
end)
--solution

so which lines of code do i delete? Everything after if property == 'Occupant' then ? Not including end. Or which lines of code do I delete?

local seat = script.Parent --Link this to the seat
local playingAnim 

local newAnim = Instance.new('Animation')
newAnim.AnimationId = 'rbxassetid://'..sitAnim

seat:GetPropertyChangedSignal("Occupant"):Connect(function(property)
   if property == 'Occupant' then
       local occupant = seat.Occupant
       if not occupant then if playingAnim then playingAnim:Stop() return end end
       playingAnim = occupant:LoadAnimation(newAnim)
       playingAnim:Play()
   end
end)
--solution```

Make sure your game is set to the animation you made it as. Like R6 as R6.

try:

playingAnim = occupant:LoadAnimation(newAnim)

seat:GetPropertyChangedSignal("Occupant"):Connect(function(property)
	if property == 'Occupant' then
		local occupant = seat.Occupant
	    if occupant ~= nil then
       	 	playingAnim:Play()
	    if occupant == nil then
			playingAnim:Stop()
		end
	  end
   end
end)

Your script has a few errors in it though. What would the variables be for occupant and those things?

local seat = script.Parent --Link this to the seat
local playingAnim
local newAnim = Instance.new('Animation')
newAnim.AnimationId = 'rbxassetid://'..sitAnim

seat:GetPropertyChangedSignal("Occupant"):Connect(function(property)
	if property == 'Occupant' then
		local occupant = seat.Occupant
        if playingAnim == nil then
            playingAnim = occupant:LoadAnimation(newAnim)
	    if occupant ~= nil then
       	 	playingAnim:Play()
	    if occupant == nil then
			playingAnim:Stop()
		end
	  end
   end
end)

Sorry about all the questions but where do i put the animation id again? In the ‘rbxassetid://’ or should i make a variable for it. Something like sitAnim = 21414

Lets say ur animationID looks like this: 4877060179

local newAnim = Instance.new('Animation')
newAnim.AnimationId = 4877060179

property is giving me an error and it doesn’t work i don’t know whats going on

local playingAnim
local newAnim = Instance.new('Animation')
local sitAnim = 28488254
local newAnim = Instance.new('Animation')
newAnim.AnimationId = 4877060179
newAnim.AnimationId = 'rbxassetid://'..sitAnim

seat:GetPropertyChangedSignal("Occupant"):Connect(function(property)
	
end)
	if property == 'Occupant' then
		local occupant = seat.Occupant
        if playingAnim == nil then
            playingAnim = occupant:LoadAnimation(newAnim)
	    if occupant ~= nil then
       	 	playingAnim:Play()
	    if occupant == nil then
			playingAnim:Stop()
		end
	  end
   end
end```

Also I think it would be neccessery to parent ur Instance, do:

local newAnim = Instance.new('Animation', game.Workspace)

it doesn’t work but I think I may have found a solution. I’m going to test it rn

This should be the right one:

local seat = script.Parent
local playingAnim
local newAnim = Instance.new('Animation', game.Workspace)
local sitAnim = 28488254
newAnim.AnimationId = sitAnim

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
		local occupant = seat.Occupant
        if playingAnim == nil then
            playingAnim = occupant:LoadAnimation(newAnim)
	   	if occupant ~= nil then
       	 	playingAnim:Play()
	   	if occupant == nil then
			playingAnim:Stop()
			end
	  	end
   	end
end)

I am pretty sure this will work, btw ur parameter “property”, was equal to nill

let me try that one then. thanks for all the help