I am coming from here https://scriptinghelpers.org/questions/3330/this-script-only-works-sometimes and although that person's issue was solved, mine still is not. I am trying to make a custom sitting animation using a seat from roblox studio. Here is the scrip i have: local seat = script.Parent
local seat = script.Parent
function SeatIsSatIn(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local character = hit.Parent
local humanoid = character.Humanoid
wait(0.2) -- 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=3788531001"
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)
I need for the animation to work every time and not just sometimes. Currently one in every 5-6 tries will play the animations and on the off times it is just a normal sit. Anyone know how to do this?
