(Disclaimer: I am very new to scripting and I'm making a vibe place to learn the basics) (music playing, animations, some building, lighting)
I was wondering how to get custom sitting animations to work in-game? I have been trying for 2 days now using many different scripts from YouTube tutorials to Roblox Dev Forum scripts but none of them work in-game? The two most notable ones I have tried will be code-blocked below...
--Epicbatteler10 (Please give only small credit :c)
---------- VARIABLES ----------
local seat = script.Parent
local sleepingR15 = seat.SleepingR15
local sleepingR6 = seat.SleepingR6
local sleepAnim
---------- CONNECTIONS ----------
seat.Changed:Connect(function(property) -- if a property in the seat changes
if property ~= "Occupant" then return end -- if that property is not "occupant" then we'll ignore the change and stop the function
local occupant = seat.Occupant
if occupant then -- if we do have an occupant then do the stuff below
local character = occupant.Parent
local humanoid = character.Humanoid
local player = game.Players:GetPlayerFromCharacter(character)
if player and humanoid.RigType == Enum.HumanoidRigType.R15 then -- checks if we're using R15
sleepAnim = humanoid:LoadAnimation(sleepingR15)
sleepAnim:Play()
elseif player then -- this is for if we're using R6
sleepAnim = humanoid:LoadAnimation(sleepingR6)
sleepAnim:Play()
end
elseif sleepAnim then -- if we don't have an occupant but the property changed that means someone just got up
sleepAnim:Stop() -- stop the sleeping animation so the player who got up isn't stuck in a sleeping animation
end
end)
This second one has been tried by me as a local script, module script, and normal script yet none of them worked ¯_(?)_/¯
local sitAnims = {5607806749, 5607806749} --Paste the same one in twice, unless you want random ones
local seat = workspace.SeatA --Link this to the seat
local playingAnim
local newAnim = Instance.new('Animation')
newAnim.AnimationId = 'rbxassetid://'..sitAnims[math.random(#sitAnims)]
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)
I have tried about 3-4 others aswell but those ones either didn't work in general or were buggy. Those two codes both work in studio but not in-game. I currently have them as "Children" to the seat(s) in the workspace. They are both just plain script.
Output Errors: RBXASSET//: Failed to load (in-game only not in studio) The Outcome: Works in studio but not in-game.
Are they in the wrong spot? Wrong type of script? Please help me lol.

2 comments
Maybe you shouldn't follow tutorials?
Thanks for the joke TTChaos but I was looking for help on the errors I may have made... If you can solve it please tell me :D