This is the module script that I had linked to it.
local module = {}
-- Services
local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerStorage")
local StarterPlayer = game:GetService("StarterPlayer")
local SoundService = game:GetService("SoundService")
local Debris = game:GetService("Debris")
-- Folders
local WeaponsSounds = SoundService.SFX.Weapons
local RSStorage = RS.Storage
local RSModules = RSStorage.Modules
local SSModules = SS.Modules
local Events = RSStorage.RemoteEvents
-- Events
local CombatEvent = Events.Combat
local VFX_Event = Events.VFX
-- Modules
local SoundsModule = require(RSModules.Combat.SoundsModule)
local ServerCombatModule = require(SSModules.CombatModule)
local WeaponStats = require(SSModules.Weapons.WeaponStats)
local HelpfulModule = require(SSModules.MISC.Helpful)
local StunHandlerV2 = require (SS.Modules.MISC.StunHandlerV2)
function module.BodyVelocity (parent, HRP, Knockback, stayTime)
local bv = Instance.new ("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge,0,math.huge)
bv.P = 50000
bv.Velocity = HRP.CFrame.LookVector * Knockback
bv.Parent = parent
Debris:AddItem(bv,stayTime)
end
function module.Normal_HitboxHit(plr,char,weapon,Hitbox,...)
local HitAnim = ...
Hitbox.OnHit:Connect(function(hit,eHum)
if eHum and eHum.Parent ~= char then
local eChar = eHum.Parent
local eHRP = eChar.HumanoidRootPart
if eHum.Health > 0 and not eChar:GetAttribute("Iframes") then
local WeaponStat = WeaponStats.getStats(weapon)
local damage = WeaponStat.Damage
local knockback = WeaponStat.Knockback
local RagdollTime = WeaponStat.RagdollTime
local stunTime = WeaponStat.StunTime
if HelpfulModule.CheckForStatus(eChar,char,damage,hit.CFrame, true,true) then return end
eHum:TakeDamage(damage)
ServerCombatModule.stopAnims(eHum)
VFX_Event:FireAllClients("CombatEffects", RSStorage.VFX.Combat.Blood, hit.CFrame, 3)
-- Highlight
VFX_Event:FireAllClients("Highlight", char and eChar,.5,Color3.fromRGB(170, 0, 0), Color3.fromRGB(255, 255, 255))
VFX_Event:FireAllClients("Highlight", char,.5,Color3.fromRGB(255, 255, 255), Color3.fromRGB(0, 0, 0))
SoundsModule.PlaySound(WeaponsSounds[weapon].Combat.Hit, eChar.Torso)
eHum.Animator:LoadAnimation(HitAnim):Play()
local CharHRP = char.HumanoidRootPart
local enemyHRP = eChar.HumanoidRootPart
local attackDirection = (CharHRP.Position - enemyHRP.Position).Unit
module.BodyVelocity (char.HumanoidRootPart, char.HumanoidRootPart, knockback, .2)
if char:GetAttribute("Combo") >= 4 then
knockback = knockback * 5
HelpfulModule.Ragdoll(eChar, RagdollTime)
end
module.BodyVelocity (eHRP, eHRP,-knockback * attackDirection, .2)
StunHandlerV2.Stun(eHum, stunTime)
end
end
end)
end
return module
And this is the server script that I had linked to the other module.
-- Services
local RS = game:GetService("ReplicatedStorage")
local SS = game:GetService("ServerStorage")
local StarterPlayer = game:GetService("StarterPlayer")
local SoundService = game:GetService("SoundService")
-- Folders
local WeaponsSounds = SoundService.SFX.Weapons
local RSStorage = RS.Storage
local RSModules = RSStorage.Modules
local SSModules = SS.Modules
local Events = RSStorage.RemoteEvents
local AnimationsFolder = RSStorage.Animations
local WeaponAnimations = AnimationsFolder.Weapons
-- Events
local CombatEvent = Events.Combat
local CritEvent = Events.Critical
-- Modules
local SoundsModule = require(RSModules.Combat.SoundsModule)
local ServerCombatModule = require(SSModules.CombatModule)
local HitService = require(SSModules.HitService)
local RayCastHitBox = require(SSModules.HitBoxes.RaycastHitboxV4)
local WeaponStats = require(SSModules.Weapons.WeaponStats)
local HelpfulModule = require (SSModules.MISC.Helpful)
-- Variables
local MaxCombo = 4
-- Main Scripting
CombatEvent.OnServerEvent:Connect(function(player)
local char = player.Character
local hum = char.Humanoid
local torso = char.Torso
if HelpfulModule.CheckForAttributes(char, true, true, true, true, true) then return end
local currentWeapon = char:GetAttribute("CurrentWeapon")
char:SetAttribute("Attacking", true)
char:SetAttribute("Swing", true)
ServerCombatModule.ChangeCombo(char)
ServerCombatModule.stopAnims(hum)
hum.WalkSpeed = 8
hum.JumpHeight = 0
--
local Hitbox = RayCastHitBox.new(char[currentWeapon])
local M1Anim = ServerCombatModule.getSwingAnimation(char,currentWeapon)
local playSwingAnimation = hum.Animator:LoadAnimation(M1Anim)
local TrailVFX = RSStorage.VFX.Weapons[currentWeapon].Trail:Clone()
TrailVFX.Parent = char[currentWeapon]
playSwingAnimation:GetMarkerReachedSignal("HitStart"):Connect(function()
Hitbox:HitStart()
-- Trail VFX
TrailVFX.Enabled = true
for i,v in pairs (TrailVFX:GetChildren()) do
if v.Name ~= "Trail2" then
v.Enabled = true
end
end
end)
playSwingAnimation:GetMarkerReachedSignal("HitEnd"):Connect(function()
Hitbox:HitStop()
-- Trail VFX
TrailVFX.Enabled = false
for i,v in pairs (TrailVFX:GetChildren()) do
if v.Name ~= "Trail2" then
v.Enabled = false
end
end
--
local WeaponStat = WeaponStats.getStats(currentWeapon)
local SwingReset = WeaponStat.SwingReset
char:SetAttribute("Swing",false)
if char:GetAttribute("Combo") == MaxCombo then
task.wait(0.5)
else
task.wait(SwingReset)
end
char:SetAttribute("Attacking", false)
end)
playSwingAnimation.Stopped:Connect(function()
Hitbox:HitStop()
if not char:GetAttribute("Swing") and not char:GetAttribute("IsBlocking") then
hum.WalkSpeed = StarterPlayer.CharacterWalkSpeed
hum.JumpHeight = StarterPlayer.CharacterJumpHeight
end
end)
playSwingAnimation:Play()
SoundsModule.PlaySound(WeaponsSounds[currentWeapon].Combat.Swing, torso)
local HitAnim = WeaponAnimations[currentWeapon].Hit["Hit"..char:GetAttribute("Combo")]
HitService.Normal_HitboxHit(player,char,currentWeapon,Hitbox,HitAnim)
end)
-- Critical
CritEvent.OnServerEvent:Connect(function(player)
local char = player.Character
local hum = char.Humanoid
local torso = char.Torso
if HelpfulModule.CheckForAttributes(char, true, true, true, true, true) then return end
local currentWeapon = char:GetAttribute("CurrentWeapon")
char:SetAttribute("Attacking", true)
char:SetAttribute("Swing", true)
ServerCombatModule.ChangeCombo(char)
ServerCombatModule.stopAnims(hum)
hum.WalkSpeed = 0
hum.JumpHeight = 0
--
local Hitbox = RayCastHitBox.new(char[currentWeapon])
local M1Anim = ServerCombatModule.getSwingAnimation(char,currentWeapon)
local playSwingAnimation = hum.Animator:LoadAnimation(M1Anim)
local TrailVFX = RSStorage.VFX.Weapons[currentWeapon].Trail:Clone()
TrailVFX.Parent = char[currentWeapon]
playSwingAnimation:GetMarkerReachedSignal("HitStart"):Connect(function()
Hitbox:HitStart()
-- Trail VFX
TrailVFX.Enabled = true
for i,v in pairs (TrailVFX:GetChildren()) do
if v.Name ~= "Trail2" then
v.Enabled = true
end
end
end)
playSwingAnimation:GetMarkerReachedSignal("HitEnd"):Connect(function()
Hitbox:HitStop()
-- Trail VFX
TrailVFX.Enabled = false
for i,v in pairs (TrailVFX:GetChildren()) do
if v.Name ~= "Trail2" then
v.Enabled = false
end
end
--
local WeaponStat = WeaponStats.getStats(currentWeapon)
local CritReset = WeaponStat.CriticalReset
char:SetAttribute("Swing",false)
if char:GetAttribute("Combo") == MaxCombo then
task.wait(0.5)
else
task.wait(CritReset)
end
char:SetAttribute("Attacking", false)
end)
playSwingAnimation.Stopped:Connect(function()
Hitbox:HitStop()
if not char:GetAttribute("Swing") and not char:GetAttribute("IsBlocking") then
hum.WalkSpeed = StarterPlayer.CharacterWalkSpeed
hum.JumpHeight = StarterPlayer.CharacterJumpHeight
end
end)
playSwingAnimation:Play()
SoundsModule.PlaySound(WeaponsSounds[currentWeapon].Combat.Swing, torso)
local HitAnim = WeaponAnimations[currentWeapon].Hit["Hit"..char:GetAttribute("Combo")]
HitService.Normal_HitboxHit(player,char,currentWeapon,Hitbox,HitAnim)
end)