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

How do i put my custom seat animation?

I've tried several Script but it doesnt work

please help here is the thing i've tried if it help

local seat = script.Parent

function SeatIsSatIn(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local character = hit.Parent
		local humanoid = character.humanoid
		wait(0.1)
		if humanoid:GetState() == Enum.HumanoidStateType.Seated then
			local animation = Instance.new("Animation")
			animation.AnimationId = "https://www.roblox.com/library/4748428498/Couch-sitting"
			local track = humanoid:Loadanimation(animation)
			track:Play()
			local function StateChanged(oldState, newState)
				if newState ~= Enum.HumanoidStateType.Seated then
					track:Stop()
				end
			end
			humanoid.StateChanged:connect(StateChanged)
		end
	end
 end
seat.Touched:Connect(SeatIsSatIn)



3 comments

0

Please put your code in a code block

0

yes please put it in a code block

0

I've edited it now it should be in a code block

1 answer

This is the script for the custom seat animation.

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)

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