所以,我想做一个简单的任务,即当你在游戏中生成时在玩家上播放动画。 我很困惑为什么它没有播放,因为我直接从 Roblox 文档中撕下了脚本(除了我添加了自己的动画)。
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
-- Ensure that the character's humanoid contains an "Animator" object
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
-- Create a new "Animation" instance and assign an animation asset ID
local myAnimation = Instance.new("Animation")
myAnimation.AnimationId = "rbxassetid://88287635939752"
-- Load the animation onto the animator
local myAnimationTrack = animator:LoadAnimation(myAnimation)
-- Play the animation track
myAnimationTrack:Play()
这是 StartPlayerScripts 中的本地脚本
我测试了动画本身,它在具有人形机器人的假人上运行得非常好。 我已经打印了所有变量的类和名称,它们都返回了它们应该返回的内容。 问题可能出在哪里?
动画似乎无法播放的原因有多种:
task.wait(5)
并再次进行游戏测试。如果您有一个简短的动画,则该动画可能是在游戏测试启动时播放的。