最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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)
发布评论

评论列表(0)

  1. 暂无评论