lua - Roblox running animation doesnt work, but the walking animation does - Stack Overflow

I created a walking animation and a running animation. I have a script in ServerScriptService that chan

I created a walking animation and a running animation. I have a script in ServerScriptService that changes the animation based on whether the player is running or walking. The walking animation works but the running animation doesnt.

I tried to change the running animation (plr.Character.Humanoid.Animate.run.RunAnim.AnimationId), but this just breaks all the animations completely

local walkingAnimation = 'rbxassetid://71361029954021'
local runningAnimation = 'rbxassetid://74605067173947'
local config = require(script.Parent.CharacterPropertiesConfig)


local function ToggleRun(plr : Player)

    local animator : Animator = plr.Character.Humanoid.Animator

    if not plr.running.Value then
        
        plr.running.Value = true
        
        plr.Character.Animate.walk.WalkAnim.AnimationId = runningAnimation
        
        
        plr.Character.Humanoid.WalkSpeed = config.RunSpeed
        plr.Character.Humanoid.JumpHeight = config.JumpHeight
        
    elseif plr.running.Value then
        
        plr.running.Value = false
        
        plr.Character.Animate.walk.WalkAnim.AnimationId = walkingAnimation
        
        plr.Character.Humanoid.WalkSpeed = config.Speed
        plr.Character.Humanoid.JumpHeight = config.JumpHeight
    
        
    end
    
end

game.Players.PlayerAdded:Connect(function(plr)
    
    plr.CharacterAdded:Connect(function(char)
        
        wait(1)
        
        char.Animate.walk.WalkAnim.AnimationId = walkingAnimation

        char.Humanoid.WalkSpeed = config.Speed
        char.Humanoid.JumpHeight = config.JumpHeight
        
    end)
    
end)

game.ReplicatedStorage.CtrlPressed.OnServerEvent:Connect(function(plr)
    
    ToggleRun(plr)
    
end)

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745663342a4638971.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信