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条)