In the process of making a blocking system and it was going pretty good up until now…
so when u punch someone 4 times, it breaks their block and plays an animation
but when i attempt to play this animation, it tells me it is not a valid member of the folder i have placed it in. line 86, error is as follows: 5 is not a valid member of Folder
Code:
local replicatedStorage = game:GetService("ReplicatedStorage")
local remote = replicatedStorage:WaitForChild("Combat")
local Debris = game:GetService("Debris")
local TweenService = game:GetService("TweenService")
local Animations = script:WaitForChild("Animations")
local enemyAnimations = script:WaitForChild("EnemyAnimations")
local Meshes = script:WaitForChild("Meshes")
local anims = {
Animations:WaitForChild("P1"),
Animations:WaitForChild("P2"),
Animations:WaitForChild("P3"),
Animations:WaitForChild("P4"),
}
local enemyAnims = {
enemyAnimations:WaitForChild("H1"),
enemyAnimations:WaitForChild("H2"),
enemyAnimations:WaitForChild("H1"),
enemyAnimations:WaitForChild("H2"),
enemyAnimations:WaitForChild("BlockBreak"),
}
local limbs = {
"Right Arm",
"Left Arm",
"Right Leg",
"Left Leg",
}
local Damage = 10
remote.OnServerEvent:Connect(function(player,count)
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local attack = humanoid:LoadAnimation(anims[count])
attack:Play()
local limb = character:WaitForChild(limbs[count])
local folder = Instance.new("Folder",character)
folder.Name = player.Name.." Melee"
local Hitbox = Meshes:WaitForChild("Hitbox"):Clone()
Hitbox.CFrame = limb.CFrame
Hitbox.Size = limb.Size
Hitbox.Material = Enum.Material.Neon
Hitbox.Parent = folder
Debris:AddItem(Hitbox,.5)
local weld = Instance.new("ManualWeld")
weld.Part0 = Hitbox
weld.Part1 = limb
weld.C0 = weld.Part0.CFrame:toObjectSpace(weld.Part1.CFrame)
weld.Parent = weld.Part0
Hitbox.Touched:Connect(function(hit)
if hit:IsA("BasePart") then
if not hit:IsDescendantOf(character) then
local enemyHumanoid = hit.Parent:FindFirstChild("Humanoid")
local enemyRootPart = hit.Parent:FindFirstChild("HumanoidRootPart")
if enemyHumanoid and enemyRootPart then
local blockAction = enemyHumanoid:FindFirstChild("blockAction")
if blockAction then
Hitbox:Destroy()
if blockAction.Value > 0 then
blockAction.Value = blockAction.Value - 1
if blockAction.Value == 0 then
local Break = enemyHumanoid:LoadAnimation(enemyAnimations[5])
Break:Play()
end
end
else
Hitbox:Destroy()
enemyHumanoid:TakeDamage(Damage)
local reaction = enemyHumanoid:LoadAnimation(enemyAnims[count])
reaction:Play()
if count == 4 then
enemyRootPart.Anchored = true
local goal = {}
goal.CFrame = CFrame.new((rootPart.CFrame * CFrame.new(0,0,-12)).p,rootPart.CFrame.p)
local info = TweenInfo.new(.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out)
local tween = TweenService:Create(enemyRootPart,info,goal)
tween:Play()
tween.Completed:Connect(function()
enemyRootPart.Anchored = false
end)
end
end
end
end
end
end)
remote.FireClient(remote,player)
end)