Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I keep my Seat Animation looping using LUA?

So I'll be honest, this isn't my script. I followed a tutorial on YouTube to make it, it works well however - I can't get the animation to loop. The Animation is self explanatory, it's sleeping, my issue is getting the animation to loop.

Also, if possible, can anyone tell me how I can remove R15 out of the script since it's essentially useless to me?

local seat = script.Parent
local sleepingR15 = seat.SleepingR15
local sleepingR6 = seat.SleepingR6
local sleepAnim



seat.Changed:Connect(function(property) 
	
	if property ~= "Occupant" then return end 
	
	local occupant = seat.Occupant
	
	if occupant then 
		local character = occupant.Parent
		local humanoid = character.Humanoid
		local player = game.Players:GetPlayerFromCharacter(character)
		if player and humanoid.RigType == Enum.HumanoidRigType.R15 then 
			sleepAnim = humanoid:LoadAnimation(sleepingR15)
			sleepAnim:Play()
		elseif player then 
			sleepAnim = humanoid:LoadAnimation(sleepingR6)
			sleepAnim:Play()
			
		end
	elseif sleepAnim then 
		sleepAnim:Stop() 
	end
end)

1 comment

0

Should also note, I'm only wanting the R6 animation to run.

1 answer

✓ Accepted answer

Set the animation to loop on properties. When you export it, you should see the option or go into the animation in the rig you made it on and set it to true/on.

2 comments

0

Ah, I didn't see there was a loop option next to the time frame. I thought it was in the same list as when you export. Thanks!

0

No problem!

This discussion is preserved as it was. New answers, comments, and votes are closed.