#unsure why animation is not running

1 messages · Page 1 of 1 (latest)

tepid chasm
#

it prints the text i have below the :Play() so it should be running, right? or at least its not getting caught up on that when the script runs

this is done within a module script located in repstorage, :Init() is being called from a localscript in startercharscripts
(this is also not the full script, but the stuff above it is completely irrelevant its just services and a couple constant variables so that shouldnt cause it)


local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
--local rootPart = char:WaitForChild("HumanoidRootPart")
local animator = hum:WaitForChild("Animator")


--Anim
local runAnim = animator:LoadAnimation(Resources.Animations.Run)


local function runSpeed(b:boolean)
    if b then
        hum.WalkSpeed = maxSpeed
        runAnim:Play()
        print("anim should be running")
    else
        hum.WalkSpeed = minSpeed
        runAnim:Stop()
        print("anim should not be running")
    end
end
    
function MovementLib:Init()
    local running = false 
    --runAnim:Play()
    UIS.InputBegan:Connect(function(i,gps)
        if gps then return end
        print("input received ", i.KeyCode)
        
        if i.KeyCode==Enum.KeyCode.LeftShift then
            running = not running
            runSpeed(running)
        end
    end)
end



return MovementLib
thorn peak
#

whenever a character is added change the animators value

tepid chasm
#

isn’t that what the top part of the script does? it wont set the animator variable until the character loads

storm berry
tepid chasm
# storm berry must move the variable definitions inside the :Init() function so they update ev...

spmething like this? (anim still aint workin but ive adjusted it to do definitions from init)

local plr:Player = nil
local char:Model = nil
local hum:Humanoid = nil
--local rootPart = char:WaitForChild("HumanoidRootPart")
local animator:Animator = nil
local runAnim:Animation = nil


--Anim



local function runSpeed(b:boolean)
    local runAnim = animator:LoadAnimation(Resources.Animations.Run)
    if b then
        hum.WalkSpeed = maxSpeed
        runAnim:Play()
        print("anim should be running")
    else
        hum.WalkSpeed =minSpeed
        runAnim:Stop()
        print("anim should not be running")
    end
end
    
function MovementLib:Init()
    local running = false 
    
    plr = game.Players.LocalPlayer
    char = plr.Character or plr.CharacterAdded:Wait()
    hum = char:WaitForChild("Humanoid")
    animator = hum:WaitForChild("Animator")
    
    runAnim = animator:LoadAnimation(Resources.Animations.Run)
    runAnim.Priority = Enum.AnimationPriority.Action
    runAnim.Looped = true
    
    UIS.InputBegan:Connect(function(i,gps)
        if gps then return end
        print("input received ", i.KeyCode)
        
        if i.KeyCode==Enum.KeyCode.LeftShift then
            running = not running
            runSpeed(running)
        else
            
        end
    end)
end



return MovementLib
storm berry
# tepid chasm spmething like this? (anim still aint workin but ive adjusted it to do definitio...

Inside your runSpeed function, you have this line:
local runAnim = animator:LoadAnimation(Resources.Animations.Run).
When you press Shift: You create a new animation track, play it, and the function ends.
When you let go of Shift (Stop Running): You create a second, completely different animation track, and call :Stop() on that one. You are stopping a track that wasn't playing, while the first track keeps playing forever.

uneven ginkgo
tepid chasm
tepid chasm
#
local MovementLib = {}

local Resources = game.ReplicatedStorage:WaitForChild("Resources")
local UIS = game:GetService("UserInputService")
local RS = game:GetService("RunService")

--Constants
local maxSpeed = 60
local minSpeed = 30

--State

local plr:Player = nil
local char:Model = nil
local hum:Humanoid = nil
--local rootPart = char:WaitForChild("HumanoidRootPart")
local animator:Animator = nil
local runAnim:Animation = nil
local running:boolean = nil


--Anim
local function runSpeed(b:boolean)
    if b and not runAnim.IsPlaying then
        hum.WalkSpeed = maxSpeed
        runAnim:Play(3)
        print("anim should be running")
    else if not b and runAnim.IsPlaying then
            runAnim:Stop(3)
            hum.WalkSpeed =minSpeed
            print("anim should not be running")
        end
    end
end
    
function MovementLib:Init()
    
    plr = game.Players.LocalPlayer
    char = plr.Character 
    hum = char:FindFirstChild("Humanoid")
    animator = hum:FindFirstChild("Animator")
    runAnim = animator:LoadAnimation(Resources.Animations.Run)
    runAnim.Priority = Enum.AnimationPriority.Action4
    runAnim.Looped = true
    
    UIS.InputBegan:Connect(function(i,gps)
        if gps then return end
        print("input began ", i.KeyCode)
        
        if i.KeyCode==Enum.KeyCode.LeftShift then
            running = true
            runSpeed(running)
        end
    end)
    
    UIS.InputEnded:Connect(function(i,gps)
        if gps then return end
        print("input ended ", i.KeyCode)

        if i.KeyCode==Enum.KeyCode.LeftShift then
            running = false
            runSpeed(running)
        end
    end)
end

return MovementLib

this is the point ive gotten to, shouldn't be any constantly reoccuring anim plays, theres only one anim, and its no longer a toggle shift

maybe its bugged out cause its a curveanimation? cause thats the only thing i can think of at this point

tepid chasm
#

double issue

#

but i set it to force r6 ._.

tepid chasm
#

NO I DIDNT. FIXED IT

#

setting anim packs to r6 and forcing r6 rig are two different things in two different locations 🙁

uneven ginkgo