最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin4PV0评论

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)
Post a comment

comment list (0)

  1. No comments so far