Hello!
I’ve recently got a problem with Stopping the animation and then Start to play the animation again. I re-did the script of it to add a new feature but now it doesn’t work at all. I tried to find the root cause of this and appears to be stopping the animation when I set the speed to 0, and doesn’t resume when I set the speed to 1.
The Code:
for i, TrainCar in pairs(TRAIN:GetChildren()) do
if TrainCar:IsA("Model") then
for i, Door in pairs(TrainCar:GetChildren()) do
if TRAIN.DoorDirection1.Value == true then
if Door.Name == "Doors11" then
if TrainCar.Body.DoorDetection1.On.Value == true then
Door.HumaniodRootPart.CanCollide = false
local Anim = Door.AnimationController:LoadAnimation(Door.Animation)
Anim:Play()
print(Anim.Speed)
end
end
if Door.Name == "Doors12" then
if TrainCar.Body.DoorDetection2.On.Value == true then
Door.HumaniodRootPart.CanCollide = false
local Anim = Door.AnimationController:LoadAnimation(Door.Animation)
Anim:Play()
end
end
else
if Door.Name == "Doors21" then
if TrainCar.Body.DoorDetection1.On.Value == true then
Door.HumaniodRootPart.CanCollide = false
local Anim = Door.AnimationController:LoadAnimation(Door.Animation)
Anim:Play()
end
end
if Door.Name == "Doors22" then
if TrainCar.Body.DoorDetection2.On.Value == true then
Door.HumaniodRootPart.CanCollide = false
local Anim = Door.AnimationController:LoadAnimation(Door.Animation)
Anim:Play()
end
end
end
end
end
end
task.wait(15)
for i, TrainCar in pairs(TRAIN:GetChildren()) do
if TrainCar:IsA("Model") then
for i, Door in pairs(TrainCar:GetChildren()) do
if TRAIN.DoorDirection1.Value == true then
if Door.Name == "Doors11" then
if TrainCar.Body.DoorDetection1.On.Value == true then
Door.HumaniodRootPart.CanCollide = false
local Anim = Door.AnimationController:LoadAnimation(Door.Animation)
Anim:AdjustSpeed(0)
end
end
if Door.Name == "Doors12" then
if TrainCar.Body.DoorDetection2.On.Value == true then
Door.HumaniodRootPart.CanCollide = false
local Anim = Door.AnimationController:LoadAnimation(Door.Animation)
Anim:AdjustSpeed(0)
end
end
else
if Door.Name == "Doors21" then
if TrainCar.Body.DoorDetection1.On.Value == true then
Door.HumaniodRootPart.CanCollide = false
local Anim = Door.AnimationController:LoadAnimation(Door.Animation)
Anim:AdjustSpeed(0)
end
end
if Door.Name == "Doors22" then
if TrainCar.Body.DoorDetection2.On.Value == true then
Door.HumaniodRootPart.CanCollide = false
local Anim = Door.AnimationController:LoadAnimation(Door.Animation)
Anim:AdjustSpeed(0)
end
end
end
end
end
end
task.wait(Time)
for i, TrainCar in pairs(TRAIN:GetChildren()) do
if TrainCar:IsA("Model") then
for i, Door in pairs(TrainCar:GetChildren()) do
if TRAIN.DoorDirection1.Value == true then
if Door.Name == "Doors11" then
if TrainCar.Body.DoorDetection1.On.Value == true then
Door.HumaniodRootPart.CanCollide = true
local Anim = Door.AnimationController:LoadAnimation(Door.Animation)
Anim:AdjustSpeed(1)
print("Speed: "..Anim.Speed)
print(Anim.IsPlaying)
print("TP: "..Anim.TimePosition)
end
end
if Door.Name == "Doors12" then
if TrainCar.Body.DoorDetection2.On.Value == true then
Door.HumaniodRootPart.CanCollide = true
local Anim = Door.AnimationController:LoadAnimation(Door.Animation)
Anim:AdjustSpeed(1)
end
end
else
if Door.Name == "Doors21" then
if TrainCar.Body.DoorDetection1.On.Value == true then
Door.HumaniodRootPart.CanCollide = true
local Anim = Door.AnimationController:LoadAnimation(Door.Animation)
Anim:AdjustSpeed(1)
end
end
if Door.Name == "Doors22" then
if TrainCar.Body.DoorDetection2.On.Value == true then
Door.HumaniodRootPart.CanCollide = true
local Anim = Door.AnimationController:LoadAnimation(Door.Animation)
Anim:AdjustSpeed(1)
end
end
end
end
end
end
Output of the Print: