Hello everyone. I've created a simple flashlight that, when equipped, triggers a simple animation; however, I noticed that the animation tends to stop at, what seems like, random times. I'm using GetMarkerReachedSignal() to detect when the animation should pause (or have the speed set to 0), and it seems to be doing that, but just not very well. I'm not great at animating so I'm not entirely sure if it's my animation or something in the script. Would greatly appreciate if someone could give me an answer as to what I'm doing wrong.
Issue: https://i.gyazo.com/64c8c9be357ef6940e5489812abc529a.gif
Script:
local toggle = false
local Db = false
local Animation_Equip = nil
script.Parent.Activated:Connect(function()
if Db == false then
Db = true
local Player = game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent)
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Toggle_Animation = Humanoid:LoadAnimation(script.Parent.ToggleF)
Toggle_Animation:Play()
Toggle_Animation:GetMarkerReachedSignal("Light_Toggle"):Connect(function()
if toggle == false then
script.Parent.Handle.SurfaceLight.Enabled = true
script.Parent.Handle.Click:Play()
toggle = true
else
script.Parent.Handle.SurfaceLight.Enabled = false
toggle = false
script.Parent.Handle.Click:Play()
end
end)
wait(1)
Db = false
end
end)
script.Parent.Equipped:Connect(function()
local Player = game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent)
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
Animation_Equip = Humanoid:LoadAnimation(script.Parent.Equip)
Animation_Equip:Play()
Animation_Equip:GetMarkerReachedSignal("Pause"):Connect(function()
Animation_Equip:AdjustSpeed(0)
end)
end)
script.Parent.Unequipped:Connect(function()
Animation_Equip:Stop()
end)
