Nevermind I fixed it. (character limit)
Is human
, Values
and debounce
set to a variable already in the script?
Yes. I forgot to include those but yes they are
could you try this:
local tasks
Values.PlayerData.IsCrouching:GetPropertyChangedSignal("Value"):Connect(function()
local CrouchAnimation = human:LoadAnimation(script.Parent.Assets.CrouchAnimation)
if Values.PlayerData.IsCrouching.Value == true then
tasks = task.spawn(function()
while task.wait() do
if human.MoveDirection.Magnitude > 0 then
CrouchAnimation:AdjustSpeed(1)
else
CrouchAnimation:AdjustSpeed(0)
end
end
end)
CrouchedTween:Play()
CrouchAnimation:Play()
elseif Values.PlayerData.IsCrouching.Value == false then
if tasks then
task.cancel(tasks)
end
CrouchAnimation:Stop()
UncrouchedTween:Play()
end
end)
Doesn’t work. The animation doesn’t seem to stop for some reason.