Need Help with Animation Load Error

np (I was literally testing on a normal part and turns out they work differently)

yeah ofcourse since a seat would make ur character sit and not move and a part would not do that

i optimizied the code further by avoiding cloning animations and instead loads the animation from the original object and it works better

game.Players.PlayerAdded:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait()
	local humanoid = character:WaitForChild("Humanoid")
	local sitTest = game.Workspace:WaitForChild("SitTest")

	for _, v in pairs(sitTest:GetChildren()) do
		if v:FindFirstChild("sitanim") then
			local db = false
			local animation = v:FindFirstChild("sitanim")

			local function playAnimation()
				if not db then
					db = true
					local animInstance = humanoid:LoadAnimation(animation)
					animInstance:Play()
					v.ChildRemoved:Connect(function()
						animInstance:Stop()
						db = false
					end)
				end
			end

			v.ChildAdded:Connect(function(hit)
				if hit.Part1.Parent == character then
					playAnimation()
				end
			end)
		end
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.