Hello,
I’m currently attempting to do just a simple switch animation for my track, however I’m unable to properly manipulate the animation in coding. It either returns to the default position, or it’ll pause briefly, but after reversing it it doesn’t seem to work again.
I’ve tried using time position & KeyframeReached / GetMarkerReachedSignal, however as a beginner scripter, I don’t really understand them. I’ve been coding this with the hopes of the animation being played inside the function I’ve already cobbled together. Currently I’m trying AnimationTrack.Stopped:Wait() but like I said before the animation just returns to the original position.
local Switched = script.Parent:FindFirstChild("Switched")
local Aa = script.Parent:FindFirstChild("Aa")
local Ba = script.Parent:FindFirstChild("Ba")
local Button = script.Parent:FindFirstChild("Button")
local Sound = script.Parent.Button:FindFirstChild("Sound")
local LArrow = script.Parent.Host.Att1:FindFirstChild("ArrowA")
local RArrow = script.Parent.Host.Att1:FindFirstChild("ArrowB")
local Ab = script.Parent.Rig:FindFirstChild("B")
local Bb = script.Parent.Rig:FindFirstChild("A")
local Anim = script.Parent.Rig.Animation
local AnimCtrl = script.Parent.Rig.AnimationController
AnimationTrack = AnimCtrl:LoadAnimation(Anim)
AnimationTrack:Play()
AnimationTrack:AdjustSpeed(0)
AnimationTrack.Looped = false
Button.Click.MouseClick:Connect(function(Act)
Switched.Value = not Switched.Value
if Switched.Value == true then
AnimationTrack:AdjustSpeed(1)
Sound:Play()
Aa.CanCollide=false
Ab.CanCollide = false
Ba.CanCollide = true
Ba.CanCollide = true
RArrow.Color = ColorSequence.new(Color3.fromRGB(0,255,0))
LArrow.Color = ColorSequence.new(Color3.fromRGB(255,0,0))
AnimationTrack.Stopped:Wait()
AnimationTrack:AdjustSpeed(0)
else
AnimationTrack:AdjustSpeed(-1)
Sound:Play()
Aa.CanCollide=false
Ab.CanCollide = false
Ba.CanCollide = true
Ba.CanCollide = true
RArrow.Color = ColorSequence.new(Color3.fromRGB(255,0,0))
LArrow.Color = ColorSequence.new(Color3.fromRGB(0,255,0))
wait(.5)
AnimationTrack:AdjustSpeed(0)
end
end)
How can i go about resolving this? Any & all help is appreciated.