local Players = game:GetService("Players")
local selectedPlayer = game:GetService('ReplicatedStorage'):WaitForChild("Events"):WaitForChild("SelectedPlayer")
local tool = script.Parent
local blade = tool:WaitForChild('Blade')
local slashAnim = tool:WaitForChild('SlashAnim')
local debounce = false
local playersHit = {}
local COOLDOWN = 1
tool.Activated:Connect(function()
if debounce then
return
end
local humanoid : Humanoid = tool.Parent:FindFirstChild("Humanoid")
if not humanoid then
warn("Humanoid not found in tool.Parent:", tool.Parent.Name)
return
end
local animator : Animator = humanoid:FindFirstChild("Animator") or Instance.new("Animator", humanoid)
local animTrack : AnimationTrack = animator:LoadAnimation(slashAnim)
--animTrack:AdjustWeight(1)
print(animator:GetPlayingAnimationTracks())
repeat task.wait() until animTrack.Length > 0
animTrack:Play()
print("Animaion ID: ", animTrack.Animation.AnimationId)
print("Animation Playing:", animTrack.IsPlaying)
print("Animation Priority:", animTrack.Priority)
debounce = true
animTrack.Stopped:Wait() -- Wait for animation to complete
debounce = false
end)
blade.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChild('Humanoid')
if not humanoid or hit.Parent == tool.Parent or playersHit[hit.Parent] or not debounce then
return
end
selectedPlayer:FireServer(humanoid)
-- Prevents overloading server when player has activated tool
playersHit[hit.Parent] = true
task.wait(COOLDOWN)
playersHit[hit.Parent] = nil
end)
控制台打印此内容。
{
[1] = ToolNoneAnim,
[2] = Animation1,
[3] = SlashAnim
} - Client - WeaponScript:25
Animaion ID: rbxassetid://107803674678292 - Client - WeaponScript:29
Animation Playing: true - Client - WeaponScript:30
Animation Priority: Enum.AnimationPriority.Action4 - Client - WeaponScript:31
原来动画是用R15制作的,而我将游戏设置为仅R6,由于两种类型之间的身体部位不同,游戏无法在R6机身上播放R15动画。
我有一个误解,R6 表示该角色是块状的,R15 表示该角色不是块状的。不过只是身体部位不同而已。