Finally, I’m nearly done with this rollercoaster known as Combat. Although, I do have a small issue, known as Knockback and table looping.
Issue One.
I would say that the combat is done, but the issue that would be prominent is to add BodyVelocity and use force + lookvector to knock your foe away. That isn’t really working at the moment as I begin to make a script such as this
local BV = Instance.new("BodyVelocity", Character)
BV.maxForce = Vector3.new(25000,25000,25000)
BV.Velocity = Character.HumanoidRootPart.CFrame.lookVector*20
game.Debris:AddItem(BV,0.3)
end
This doesn’t even give an error; it simply just does nothing.
If that was the only issue, I feel like I would’ve been able to get through it, but at the same time the combat that was doing the damage I originally wanted is now bugging and cannot play without being a full part of the for loop just looping damage for each part I believe, so I had to lower the damage drastically, and the damage is somewhat randomized depending on how much surface area the Hitbox will get.
--Hitbox Creation
local HitBox = HiBo:Clone()
HitBox.CFrame = Character.PrimaryPart.CFrame * CFrame.new(0, 0, -3)
local Welds = Instance.new("WeldConstraint", Character.PrimaryPart)
Welds.Part0 = HitBox
Welds.Part1 = Character.PrimaryPart
HitBox.Parent = workspace
--Region3 Creation
local pos1 = HitBox.Position - (HitBox.Size/2)
local pos2 = HitBox.Position + (HitBox.Size/2)
local Re3 = Region3.new(pos1, pos2)
--Region3 In Action
local HBFinder = workspace:FindPartsInRegion3(Re3, HitBox, 20)
Debris:AddItem(HitBox, 0.3)
for i, parts in pairs (HBFinder) do
if parts.Parent:FindFirstChild("Humanoid") and parts.Parent ~= Character then
print(parts.Name)
--print("The Humanoid was most definitely hit.")
parts.Parent.Humanoid:TakeDamage(0.95)
local BV = Instance.new("BodyVelocity", Character)
BV.maxForce = Vector3.new(25000,25000,25000)
BV.Velocity = Character.HumanoidRootPart.CFrame.lookVector*20
game.Debris:AddItem(BV,0.3)
end
--DiedEffect
if Humanoid.Died then
Humanoid.Died:Connect(function()
if Humanoid.Died then
HitBox:Destroy()
script.Disabled = true
else
return not Humanoid.Died
end
end)--Died Function
end
end
end
end) --Ofc Main Function
At this point I cannot figure out what to do after trying different methods such as separating the damage from the loop, making the loop a generalized thing.
And as for the Knockback I have tried to no avail to fix it.