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

How can I make it so when someone sits in a seat, it applys an animation I made to them?

2 answers

✓ Accepted answer

The Humanoid Instance has an invisible property called HumanoidStateType, this tells you what the Humanoid is doing (Sitting, Running, Dead, Jumping, and more!) So you can write a function like this:

If your script is inside the seat:

local seat = script.Parent

function SeatIsSatIn(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		local character = hit.Parent
		local humanoid = character.Humanoid
		wait(0.5) -- Wait a little bit so that the character has time to sit.
		if humanoid:GetState() == Enum.HumanoidStateType.Seated then -- Make sure the humanoid is sitting
			local animation = Instance.new("Animation")
			animation.AnimationId = "http://www.roblox.com/asset/?id=182435998" -- Put your AnimationID here, currently Gangnam Style
			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)

2 comments

0

@Unlimitus, I made this account just to say thanks! I really needed that script.

0

Strange. now its not working

Whenever you sit on a seat it applies a weld when you touch it, you'd probably have to make your own custom seat.

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