Custom seat not working!

hello im making a game with custom sitting animations (more then 1) and its not working for me but i gave up trying to find the solution on my own and im looking for help.

my sit animation wont work no matter what i do this is the animation rbxassetid://6707030668
and this is the script im using

seat = script.Parent
function added(child)
   if (child.className=="Weld") then
   	human = child.part1.Parent:FindFirstChild("Humanoid")
   	if human ~= nil then
   		anim = human:LoadAnimation(seat.sitanim)
   		anim:Play()
   	end
   end
end

function removed(child2)
   if anim ~= nil then
   	anim:Stop()
   	anim:Remove()
   end
end

seat.ChildAdded:connect(added)
seat.ChildRemoved:connect(removed)

thanks for your time helping!

1 Like

There are multiple things that could be going wrong. The first thing I would suggest is to add Print() statements throughout the code to make sure that it is actually executing.

But also, do you own this animation? Make sure it is your own animation that you have uploaded otherwise it won’t work. Another thing, if it is a group place, the animations will work for whoever made them but not anyone else who plays, until the game is published. Do make sure it is not a problem playing the animation, and not a problem with the code itself.

Try directly changing the sitting animation. I’ve helped someone with the exact same script as you and this is what I gave

local seat = script.Parent
local animId = seat.sitanim.AnimationId
local defaultAnim = "http://www.roblox.com/asset/?id=2506281703"
local formeroccupant

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	local humanoid = seat.Occupant
	if humanoid then
		local char = humanoid.Parent
		char.Animate.sit.SitAnim.AnimationId = animId
		formeroccupant = char
	else			
		formeroccupant.Animate.sit.SitAnim.AnimationId = defaultAnim
		formeroccupant = nil
	end
end)

What this does is change the sitting aniamtion of whoever is sitting to the custom one you hae and when they get up, return it back to the default. Not sure if you need to do anyt changes cause fro mthe looks of it, yours and the one I helped are the same scripts

If this doesn’t work either, as stated above, you have to own the animation to use it, although not sure if the same applies if you just edit the animation id

There can probably be other issues such as the wrong rig types (trying to play an R6 animation on an R15 body and vice versa), wrong id, ownership of the animation itself, etc

i think it works but it works on every seat

What do you mean by it works on every seat?

like i want to test it in play test and i sit in the seat i want it to work- it works . i sit in another and its the same animation
https://gyazo.com/38a4fff7bd8cca00df31d408cd583b1b

Not sure if this has to be

local defaultAnim = "rbxassetid://2506281703"

If that doesn’t work either, did you remember to change the IDs/ use the script on the other seats?

ye i changed the animation id too this is what i changed it too

local seat = script.Parent
local animId = seat.sitanim.AnimationId
local defaultAnim = "http://www.roblox.com/asset/?id=6707030668"
local formeroccupant

seat:GetPropertyChangedSignal("Occupant"):Connect(function()
	local humanoid = seat.Occupant
	if humanoid then
		local char = humanoid.Parent
		char.Animate.sit.SitAnim.AnimationId = animId
		formeroccupant = char
	else			
		formeroccupant.Animate.sit.SitAnim.AnimationId = defaultAnim
		formeroccupant = nil
	end
end)

Do not change the defaultAnim variable, keep it has how I wrote it, it’s to return the animation back to the default sitting animation

im confussed now, what do oyu mean? i only changed the animation link so it plays the animation i want and i made.

Change the defaultANim ariable to this

local defaultAnim = "http://www.roblox.com/asset/?id=2506281703"

Keep it as how I wrote it, you just need to tweak the animation id in the sitanim animationTrack

where isthe sitanim animation track??

sorry im just confussed on this a bit

Sorry about my late response, I was asleep.

Basically what I mean is that, keep the defaultAnim variable the same, don’t change that. From what I can tell, you have a child in the seat called sitanim, if you just want to change the animation, just change the AnimationId property of sitanim

so sorry again but i still simply just dont understand lol i feel really bad im sorry

It’s fine!

Basically, you know how you have something in the seat in the explorer called sitanim? You just change the AnimationId property of it to the id of the animation you want it to play. Keep the defaultAnim variable in the script the same