I am following this youtube tutorial: Roblox Sword Combat Tutorial Part 1 - YouTube
and is at around the 15 minutes section, however, the animation is not playing like it is in the video.
here is the script:
---import animation here---
local swingAnims = {
'rbxassetid://10361309646',
'rbxassetid://10361362203',
'rbxassetid://10361390995',
'rbxassetid://10361426144',
'rbxassetid://10361455455'
}
---setup---
local t = game:GetService("TweenService")
local rs = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")
local resource = rs.Combat.Sword
local fx = resource.Fx
local remote = rs.Remotes.Combat
local p = game.Players.LocalPlayer
local c = script.Parent
local hrp = c.HumanoidRootPart
local combo = 1
local lasthit = 0
local cd = false
local anim = script:WaitForChild("Animation")
local function setUp(char)
local handle = fx.Handle:Clone()
handle.Parent = char
local m6d = Instance.new("Motor6D", handle)
m6d.Part0 = char.RightHand --Replace with .RightArm if using R6
m6d.Part1 = handle
m6d.C1 = CFrame.new(0,0,0) -- Handle Offset
local model = fx.Sword:Clone()
model.Parent = workspace.Fx
local weld = Instance.new("Weld", model)
weld.Part0 = handle
weld.Part1 = model
weld.C1 = CFrame.new(3,0,0) * CFrame.Angles(math.rad(90),math.rad(90),0) --Sword Offset + Rotation
end
for i,v in pairs(game.Players:GetChildren()) do
repeat wait() until v.Character
setUp(v.Character) --Setup upon joining
v.CharacterAdded:Connect(function(char)
char:WaitForChild("RightHand") --Replace with "RightArm" if using R6
setUp(char) --Setup upon respawn
end)
end
local function slash(char, comboN)
end
uis.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 and not cd and c:FindFirstChild("Stun") == nil then
c.Humanoid.WalkSpeed = 0
c.Humanoid.JumpPower = 0
if tick() - lasthit > 1 then
combo = 1
end
lasthit = tick()
cd = true
anim.AnimationId = swingAnims[combo]
local load = c.Humanoid:LoadAnimation(anim) -- Sets load as animation to be accessed later
print(load.AnimationId)
load.Priority = Enum.AnimationPriority.Action
print("e")
load:Play()
print("2")
local data = {char = c, comboN = combo, action = "slash"}
remote:FireServer(data)
slash(c, combo)
if combo == 5 then
combo = 1
else
combo += 1
end
wait(0.1)
cd = false
c.Humanoid.WalkSpeed = 16
c.Humanoid.JumpPower = 50
end
end)
instead of playing the animation, it just acts like the load:play() didn’t exist
I have also tried loading the animation onto the animator instead of the humanoid.
this is in a local script btw