Trying to make a simple jab, although I’m getting an error about the if statement… Heres my code:
local Event = game.ReplicatedStorage.CombatEvents.Jab
game.ReplicatedStorage.CombatEvents.Jab.OnServerEvent:Connect(function(Player, Action)
local c = Player.Character
if Action == "Jab1" and not c:FindFirstChild("Conditions"):FindFirstChild("IsStunned").Value == true then
for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("HumanoidRootPart") then
local vector = (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position)
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
if (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 then
v.Conditions.IsAttacking.Value = true
local CurrentDamage = v.Conditions.CurrentDamage
v.Humanoid:TakeDamage(1)
CurrentDamage.Value += 1
if v:FindFirstChild("BillboardGui"):FindFirstChild("TextLabel") then
v.BillboardGui.TextLabel.Text = CurrentDamage.Value .. "%"
end
v.Conditions.IsAttacking.Value = false
elseif (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 and v.Conditions.IsBlocking.Value == true then
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
v.Conditions.IsAttackedWhileBlocking.Value = true
end
end
end
end
end
elseif Action == "Jab2" and not c:FindFirstChild("Conditions"):FindFirstChild("IsStunned").Value == true then
for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("HumanoidRootPart") then
local vector = (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position)
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
if (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 then
v.Conditions.IsAttacking.Value = true
local CurrentDamage = v.Conditions.CurrentDamage
v.Humanoid:TakeDamage(2)
CurrentDamage.Value += 2
if v:FindFirstChild("BillboardGui"):FindFirstChild("TextLabel") then
v.BillboardGui.TextLabel.Text = CurrentDamage.Value .. "%"
end
v.Conditions.IsAttacking.Value = false
elseif (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 and v.Conditions.IsBlocking.Value == true then
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
v.Conditions.IsAttackedWhileBlocking.Value = true
end
end
end
end
end
end
elseif Action == "Jab3" and not c:FindFirstChild("Conditions"):FindFirstChild("IsStunned").Value == true then
for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("HumanoidRootPart") then
local vector = (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position)
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
if (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 then
v.Conditions.IsAttacking.Value = true
local CurrentDamage = v.Conditions.CurrentDamage
v.Humanoid:TakeDamage(3)
CurrentDamage.Value += 3
if v:FindFirstChild("BillboardGui"):FindFirstChild("TextLabel") then
v.BillboardGui.TextLabel.Text = CurrentDamage.Value .. "%"
end
local Force = Instance.new("BodyVelocity")
Force.Parent = v.HumanoidRootPart
Force.MaxForce = Vector3.new(5000, math.floor(math.random(50,200)), 0)
CurrentDamage.Value += 125
Force.Velocity = c.HumanoidRootPart.CFrame.LookVector * CurrentDamage.Value*2
print(Force.Velocity)
game.Debris:AddItem(Force, 0.3)
v.Conditions.IsAttacking.Value = false
elseif (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 and v.Conditions.IsBlocking.Value == true then
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
v.Conditions.IsAttackedWhileBlocking.Value = true
end
end
end
end
end
end
end
end)
local Event = game.ReplicatedStorage.CombatEvents.Jab
game.ReplicatedStorage.CombatEvents.Jab.OnServerEvent:Connect(function(Player, Action)
local c = Player.Character
if Action == "Jab1" and not c:FindFirstChild("Conditions"):FindFirstChild("IsStunned").Value == true then
for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("HumanoidRootPart") then
local vector = (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position)
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
if (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 then
v.Conditions.IsAttacking.Value = true
local CurrentDamage = v.Conditions.CurrentDamage
v.Humanoid:TakeDamage(1)
CurrentDamage.Value += 1
if v:FindFirstChild("BillboardGui"):FindFirstChild("TextLabel") then
v.BillboardGui.TextLabel.Text = CurrentDamage.Value .. "%"
end
v.Conditions.IsAttacking.Value = false
elseif (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 and v.Conditions.IsBlocking.Value == true then
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
v.Conditions.IsAttackedWhileBlocking.Value = true
end
end
end
end
end
elseif Action == "Jab2" and not c:FindFirstChild("Conditions"):FindFirstChild("IsStunned").Value == true then
for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("HumanoidRootPart") then
local vector = (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position)
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
if (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 then
v.Conditions.IsAttacking.Value = true
local CurrentDamage = v.Conditions.CurrentDamage
v.Humanoid:TakeDamage(2)
CurrentDamage.Value += 2
if v:FindFirstChild("BillboardGui"):FindFirstChild("TextLabel") then
v.BillboardGui.TextLabel.Text = CurrentDamage.Value .. "%"
end
v.Conditions.IsAttacking.Value = false
elseif (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 and v.Conditions.IsBlocking.Value == true then
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
v.Conditions.IsAttackedWhileBlocking.Value = true
end
end
end
end
end
end
elseif Action == "Jab3" and not c:FindFirstChild("Conditions"):FindFirstChild("IsStunned").Value == true then
for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("HumanoidRootPart") then
local vector = (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position)
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
if (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 then
v.Conditions.IsAttacking.Value = true
local CurrentDamage = v.Conditions.CurrentDamage
v.Humanoid:TakeDamage(3)
CurrentDamage.Value += 3
if v:FindFirstChild("BillboardGui"):FindFirstChild("TextLabel") then
v.BillboardGui.TextLabel.Text = CurrentDamage.Value .. "%"
end
local Force = Instance.new("BodyVelocity")
Force.Parent = v.HumanoidRootPart
Force.MaxForce = Vector3.new(5000, math.floor(math.random(50,200)), 0)
CurrentDamage.Value += 125
Force.Velocity = c.HumanoidRootPart.CFrame.LookVector * CurrentDamage.Value*2
print(Force.Velocity)
game.Debris:AddItem(Force, 0.3)
v.Conditions.IsAttacking.Value = false
elseif (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 and v.Conditions.IsBlocking.Value == true then
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
v.Conditions.IsAttackedWhileBlocking.Value = true
end
end
end
end
end
end)
I’m still getting an error…
I used your code yet I still got an error, even though I corrected the mistake you made for the if statement, what should I do now?!
game.ReplicatedStorage.CombatEvents.Jab.OnServerEvent:Connect(function(Player, Action)
local c = Player.Character
if Action == "Jab1" and not c:FindFirstChild("Conditions"):FindFirstChild("IsStunned").Value == true then
for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("HumanoidRootPart") then
local vector = (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position)
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
if (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 then
v.Conditions.IsAttacking.Value = true
local CurrentDamage = v.Conditions.CurrentDamage
v.Humanoid:TakeDamage(1)
CurrentDamage.Value += 1
if v:FindFirstChild("BillboardGui"):FindFirstChild("TextLabel") then
v.BillboardGui.TextLabel.Text = CurrentDamage.Value .. "%"
end
v.Conditions.IsAttacking.Value = false
elseif (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 and v.Conditions.IsBlocking.Value == true then
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
v.Conditions.IsAttackedWhileBlocking.Value = true
end
end
end
end
end
elseif Action == "Jab2" and not c:FindFirstChild("Conditions"):FindFirstChild("IsStunned").Value == true then
for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("HumanoidRootPart") then
local vector = (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position)
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
if (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 then
v.Conditions.IsAttacking.Value = true
local CurrentDamage = v.Conditions.CurrentDamage
v.Humanoid:TakeDamage(2)
CurrentDamage.Value += 2
if v:FindFirstChild("BillboardGui"):FindFirstChild("TextLabel") then
v.BillboardGui.TextLabel.Text = CurrentDamage.Value .. "%"
end
v.Conditions.IsAttacking.Value = false
elseif (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 and v.Conditions.IsBlocking.Value == true then
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
v.Conditions.IsAttackedWhileBlocking.Value = true
end
end
end
end
end
elseif Action == "Jab3" and not c:FindFirstChild("Conditions"):FindFirstChild("IsStunned").Value == true then
for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("HumanoidRootPart") then
local vector = (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position)
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
if (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 then
v.Conditions.IsAttacking.Value = true
local CurrentDamage = v.Conditions.CurrentDamage
v.Humanoid:TakeDamage(3)
CurrentDamage.Value += 3
if v:FindFirstChild("BillboardGui"):FindFirstChild("TextLabel") then
v.BillboardGui.TextLabel.Text = CurrentDamage.Value .. "%"
end
local Force = Instance.new("BodyVelocity")
Force.Parent = v.HumanoidRootPart
Force.MaxForce = Vector3.new(5000, math.floor(math.random(50,200)), 0)
CurrentDamage.Value += 125
Force.Velocity = c.HumanoidRootPart.CFrame.LookVector * CurrentDamage.Value*2
print(Force.Velocity)
game.Debris:AddItem(Force, 0.3)
v.Conditions.IsAttacking.Value = false
elseif (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 and v.Conditions.IsBlocking.Value == true then
if vector:Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
v.Conditions.IsAttackedWhileBlocking.Value = true
end
end
end
end
end
end
end)