I was wondering how I would add a feature like this:
Into my m1s:
This is my first time scripting in combat tell me if there’s anything bad I’m doing in my script let me know. I need some ideas on how to implement it because now I have no idea what to start on.
This is the Server Sided Script that I’m using.
-- 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
local VFX_Event = Events.VFX
-- 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(1)
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)
And this is the Cliented Sided Script I’m using
-- Services
local RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
-- Player
local Player = game:GetService("Players").LocalPlayer
local Char = Player.Character
-- Folders
local RSStorage = RS.Storage
local Events = RSStorage.RemoteEvents
-- Events
local CombatEvent = Events.Combat
local CritEvent = Events.Critical
-- Main Scripting
UIS.InputBegan:Connect(function(Input, GPE)
if GPE then return end
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
CombatEvent:FireServer("Swing")
end
end)
-- Critical
UIS.InputBegan:Connect(function(Input, GPE)
if GPE then return end
if Input.KeyCode == Enum.KeyCode.R then
CritEvent:FireServer("Block")
end
end)