Hello,
Recently, I made a script that stops playing an animation when the player gets out of the seat however it has come to my attention that the script is bugged and when the player gets out of the seat animations for all players are stopped even if they did not get up. Assistance on this would be appreciated.
local function stopAllAnimations()
local character = script.Parent.Parent
local humanoid = character:WaitForChild("Humanoid")
if not humanoid then return end
-- Stop all animations
for _, track in ipairs(humanoid:GetPlayingAnimationTracks()) do
track:Stop()
end
end
seat1:GetPropertyChangedSignal("Occupant"):Connect(function()
local character = game:GetService("Players").LocalPlayer.Character or game:GetService("Players").LocalPlayer.CharacterAdded:Wait()
local playingAnim1 = character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(newAnim1)
local occupant = seat1.Occupant
if occupant == character:FindFirstChild("Humanoid") then
ANIMPLAYING = true
playingAnim1:Play()
end
if occupant == nil then
ANIMPLAYING=false
stopAllAnimations()
end
end)