-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathKnockback_Module.lua
More file actions
39 lines (31 loc) · 1.18 KB
/
Knockback_Module.lua
File metadata and controls
39 lines (31 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
--//Made By Ic35k_Jason
local ApplyKnockBack = {}
ApplyKnockBack.__index = ApplyKnockBack
function ApplyKnockBack.new(EnemyCharacter: Model,Character: Model,Range: number,Height: number)
local self = setmetatable({
_EnemyCharacter = EnemyCharacter;
_Character = Character;
_Range = Range;
_Height = Height;
},ApplyKnockBack)
return self
end
function ApplyKnockBack:CalculateMass(Model: Model)
assert(Model and Model:IsA("Model"),"Type[Model] Argument Must Be Model!")
local TotalMass = 0;
for _,Values in pairs(Model:GetDescendants()) do
if (Values:IsA("BasePart")) then
TotalMass += Values.AssemblyMass;
end
end
return TotalMass
end
function ApplyKnockBack:Construct()
local Character = self._Character
local EnemyCharacter = self._EnemyCharacter
local Range = self._Range
local Height = self._Height
EnemyCharacter.PrimaryPart:SetNetworkOwner(nil)
EnemyCharacter.PrimaryPart:ApplyImpulse(Character.PrimaryPart.CFrame.LookVector * ApplyKnockBack:CalculateMass(EnemyCharacter) * Range + Vector3.new(0, ApplyKnockBack:CalculateMass(EnemyCharacter) * Height, 0))
end
return ApplyKnockBack