Gonna be straight to the point since I don’t feel like taking about 3 days working on something ‘simple’ and it just doesn’t work.
I have a script, which is for charging a certain throw animation. Now, I have a certain name at a keyframe for this animation, and when this name is hit, it will stop a previous loop and go into a different function/action. The issue is that it only does it this occasionally.
Both these videos have the exact same script, yet in one session, it works better than the other besides the speed not adjusting back to it’s normal.
local KeyFrameReached = ThrowAnimation.KeyframeReached:Connect(function(keyframeName)
repeat
if keyframeName == "ReleaseLoop" then
RL = keyframeName
end
until RL == "ReleaseLoop"
end)
This is what is handling/happening to the loop that I am dealing with. It’s just constantly updating a variable that I am using to check out if it hit said KeyFrame.
if GUIACTIVE == true then
ThrowAnimation:GetMarkerReachedSignal("SlowDownCharge"):Connect(function()
ThrowAnimation:AdjustSpeed(0.1)
if not RL then
while not RL do
task.wait(0.001)
Left = TweenService:Create(Slider, TI, {Position = UDim2.new(0.572, 0, 0.556, 0)})
Right = TweenService:Create(Slider, TI, {Position = UDim2.new(0.646, 0, 0.556, 0)})
local LPB = Left:GetPropertyChangedSignal("PlaybackState")
local RPB = Right:GetPropertyChangedSignal("PlaybackState")
print(RL)
local function LEFTTOSS(pb)
pb = Left.PlaybackState
if pb == Enum.PlaybackState.Completed then
Right:Play()
end
end
local function RIGHTTOSS(pb)
pb = Right.PlaybackState
if pb == Enum.PlaybackState.Completed then
Left:Play()
end
end
local Tween = Randomization()
if Tween == "LeftTween" then
LPB:Connect(LEFTTOSS)
RPB:Connect(RIGHTTOSS)
Left:Play()
elseif Tween == "RightTween" then
RPB:Connect(RIGHTTOSS)
LPB:Connect(LEFTTOSS)
Right:Play()
end
end
elseif RL then
print(RL)
KeyFrameReached:Disconnect()
Left:Cancel()
Right:Cancel()
ThrowAnimation:GetMarkerReachedSignal("Toss"):Connect(function()
ThrowAnimation:AdjustSpeed(1)
FruitActions:FireServer()
end)
end
end)
end
end
end
I have been looking through, and found that my issue was that my variables aren’t consistently checked within the scripts, so I don’t have a completely proper way to counteract it, and there is no proper “changed” event for a normal variable.