How would I be able to make it so when someone sits in a seat in your game, it makes them do a sit animation, that I made, until they get out of the seat? I made a sit animation, but I just can't figure out how to apply it to a player when they are sitting.
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)
Whenever you sit on a seat it applies a weld when you touch it, you'd probably have to make your own custom seat.