How to run animations over and over again when the player is sitting on a specific seat?

I am trying to add an animation that will go around in circles when the player is sitting on a specific seat.

The server script, which is located in the seat, spawns the player on the seat, and is intended to run the animation over and over again until the player leaves the seat.

This was my previous working script.
local players = game:GetService('Players')
players.PlayerAdded:Connect(function(player)
	local added
	added = player.CharacterAdded:Connect(function(character)
		added:Disconnect()
		task.wait(0.1)
		local humanoid = character:WaitForChild('Humanoid')
		humanoid.JumpPower = 0
		while not humanoid.Sit do
			character:WaitForChild('HumanoidRootPart').CFrame = script.Parent.CFrame
			task.wait()
			humanoid.JumpPower = 50
		end
	end)
end)
This is my current, updated script.
local players = game:GetService('Players')
players.PlayerAdded:Connect(function(player)
	local added
	added = player.CharacterAdded:Connect(function(character)
		added:Disconnect()
		task.wait(0.1)
		local humanoid = character:WaitForChild('Humanoid')
		humanoid.JumpPower = 0
		
		local animation = Instance.new("Animation")
		animation.AnimationId = "https://www.roblox.com/library/9696052308/Keyboard-Typing"
		local animationTrack = humanoid:LoadAnimation(animation)
		
		animationTrack:Play()
		while not humanoid.Sit do
			character:WaitForChild('HumanoidRootPart').CFrame = script.Parent.CFrame
			task.wait()
			humanoid.JumpPower = 50
		end
	end)
end)

Unfortunately, an error pops up on the output:

Invalid animation id ‘<error: id not found in first 128 char for http AssetId>’: - Server - Script:12

and

12:35:39.770 Infinite yield possible on ‘Workspace:WaitForChild(“Humanoid”)’ - Studio

I tried to change something but it doesn’t work.
I used the article:
https://developer.roblox.com/en-us/api-reference/class/Animation

Have I done something wrong?

1 Like

I think this means the AnimationId you have inputted does not exist / is wrong. You may need to check the Id again.

Did you try looping the animation?

@afampany @Mr_baconhair839 It didn’t changed anything ~ The errors were the same

I know why. This is because you are only supposed to type in the Id, which is the part after ‘library/’, so it would be 9696052308 and not the entire link.

This should work.

Hope this helped!

Unfortunately, it didn’t help. An error popped up which marked me with an incorrect id type. After that, nothing has changed.

wouldn’t it be like this?

rbxassetid://9696052308
2 Likes

"https://www.roblox.com/catalog/9696052308" -- Web URL (will not work)
"http://www.roblox.com/asset/?id=9696052308" -- Content ID (will work)
"rbxassetid://9696052308" -- Content ID (alternative version, will work)

Use these 2 formats, not web one.

2 Likes

I think it should work with this format. Ah yes, that’s why. My apologies, @KotyOceloty.

1 Like

when you make the anim loop it and just do anim:Stop() when you leave the seat

1 Like