Hello! I’m working on a module script for my super smash bros game that takes any angle and turns it into a CFrame value for my knockback. For example, an uptilt would launch you straight up while just a jab would send you mostly horizontally. How would I implement this? Here is what I have so far:
local CharModule = {
--First character: Mario
["Mario"] = {
--Mario Stats
["Stats"] = {
["Weight"] = 100;
["BaseKnockBack"] = 20;
["KnockBackGrowth"] = 100
}
}
}
function CharModule:Attack(c, Range, Damage, Knockback, Force, Height)
for i, v in pairs(game.Workspace:GetChildren()) do
if v:IsA("Model") and v:FindFirstChild("HumanoidRootPart") then
if (c.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude < 5 then
if ((c.HumanoidRootPart.Position - v.HumanoidRootPart.Position)):Dot( c.HumanoidRootPart.CFrame.lookVector ) < 0 then
v.Conditions.IsAttacking.Value = true
local CurrentDamage = v.Conditions.CurrentDamage
v.Humanoid:TakeDamage(Damage)
CurrentDamage.Value += 1
if v:FindFirstChild("BillboardGui"):FindFirstChild("TextLabel") then
v.BillboardGui.TextLabel.Text = CurrentDamage.Value .. "%"
end
if Knockback == true then
local Vel = Instance.new("BodyVelocity")
Vel.Parent = v.HumanoidRootPart
Vel.MaxForce = Vector3.new(5000, math.floor(math.random(5000)), 0)
local Weight = CharModule["Mario"]["Stats"]["Weight"]
local BKB = CharModule["Mario"]["Stats"]["BaseKnockBack"]
local KBG = CharModule["Mario"]["Stats"]["KnockBackGrowth"]
Vel.Velocity = c.HumanoidRootPart.CFrame.LookVector *(Weight/4)+Vector3.new(CurrentDamage.Value*Force/1.25, Height, 0)
game.Debris:AddItem(Vel, 0.3)
v.Conditions.IsAttacking.Value = false
end
end
end
end
end
end
return CharModule
Please help!