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)
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
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)
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
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