This is really old code I took from the marketplace and I’m having 2 errors here’s the code:
game:GetService("Players").PlayerAdded:Connect(function(PLR)
PLR.CharacterAdded:Connect(function(Char)
local Hum = Char:WaitForChild("Humanoid")
local HRP = Char:WaitForChild("HumanoidRootPart")
local HitChars = {}
local Swinging = false
game:GetService("RunService").Heartbeat:Connect(function()
local Anims = Hum:GetPlayingAnimationTracks()
local Attacking = false
local AttackAnim = 1
for Index, Anim in pairs(Anims) do
if Anim.Animation.AnimationId == game.ReplicatedStorage.CombatSystem.CombatAnimations.Block.AnimationId then
Attacking = false
end
if Anim.Animation.AnimationId == game.ReplicatedStorage.CombatSystem.CombatAnimations.LeftPunch.AnimationId then
AttackAnim = 1
Attacking = true
end
if Anim.Animation.AnimationId == game.ReplicatedStorage.CombatSystem.CombatAnimations.RightPunch.AnimationId then
AttackAnim = 2
Attacking = true
end
end
if Attacking == true then
local ray = Ray.new(HRP.Position, HRP.CFrame.LookVector * 3)
local Part, position = game.Workspace:FindPartOnRay(ray, Char)
if Part and Part.Parent:FindFirstChild("Humanoid") and not HitChars[Part.Parent] then
local EnemyAnimations = Part.Parent.Humanoid:GetPlayingAnimationTracks()
local Blocking = false
for Index, Anim in pairs(EnemyAnimations) do
if Anim.Animation.AnimationId == game.ReplicatedStorage.CombatSystem.CombatAnimations.Block.AnimationId then
Blocking = true
end
end
if Blocking == false then
HitChars[Part.Parent] = true
local BV = Instance.new("BodyVelocity")
BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
BV.Velocity = HRP.CFrame.LookVector * 50 + Vector3.new(0, 10, 0)
BV.Parent = Part.Parent.HumanoidRootPart
game:GetService("Debris"):AddItem(BV, 0.1)
if Part.Parent.UpperTorso:FindFirstChild("HitEffect") then
else
local HitEffect = game.ReplicatedStorage.CombatSystem.Effects.HitEffect:Clone()
HitEffect.Parent = Part.Parent.UpperTorso
game:GetService("Debris"):AddItem(HitEffect, 2)
end
end
if AttackAnim == 1 then
local PunchSound = game.ReplicatedStorage.CombatSystem.Sounds.Punched1:Clone()
PunchSound.Playing = true
PunchSound.Parent = Char.LeftHand
game:GetService("Debris"):AddItem(PunchSound, 1)
else
local RightPunch = game.ReplicatedStorage.CombatSystem.Sounds.Punched2:Clone()
RightPunch.Playing = true
RightPunch.Parent = Char.RightHand
game:GetService("Debris"):AddItem(RightPunch, 1)
end
end
Part.Parent.Humanoid:TakeDamage(10)
task.wait(0.5)
HitChars[Part.Parent] = nil
else
local BlockEffect = game.ReplicatedStorage.CombatSystem.Effects.BlockEffect:Clone()
BlockEffect.Parent = Part.Parent.Torso or Part.Parent.UpperTorso
game:GetService("Debris"):AddItem(BlockEffect, 2)
end
end
end
end)
end)
end)
game.ReplicatedStorage.CombatSystem.Punching.OnServerEvent:Connect(function(PLR)
if game.Workspace[PLR.Name].HumanoidRootPart:FindFirstChild("Swing") then
game.Workspace[PLR.Name].HumanoidRootPart.Swing:Play()
else
game.ReplicatedStorage.CombatSystem.Sounds.Swing:Clone().Parent = game.Workspace[PLR.Name].HumanoidRootPart
game.Workspace[PLR.Name].HumanoidRootPart.Swing:Play()
end
end)
There are errors on lines 71 (Regarding “Part”), and 7-78 (Regarding a missing “)” )
And if whoever is reading this is super bored id be nice if you replaced the Body Velocity with apply impulse.