I created this script to play an animation while seating but it doesnt work , it work with an ordinary roblox animation but when i use mine it doesnt work ... I already choose all stage of permission but it doesnt work .
Here the sript:
local seat = script.Parent
function SeatIsSatIn(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local character = hit.Parent
local humanoid = character.Humanoid
wait(0.5)
if humanoid:GetState() == Enum.HumanoidStateType.Seated then
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://3160530487"
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)

1 comment
Try using humanoid.Seated:Connect(function()