Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- A short recent combat script, the bottom is a bit messy.
- local Players = game:GetService("Players")
- local RepStorage = game:GetService("ReplicatedStorage")
- local Debris = game:GetService("Debris")
- local ServerModules = script.Parent.Parent
- local RepModules = RepStorage:WaitForChild("Modules")
- local Data = RepModules:WaitForChild("Data")
- local Controllers = ServerModules:WaitForChild("Controllers")
- local DamageController = require(Controllers:WaitForChild("DamageController"))
- local RagdollModule = require(RepModules:WaitForChild("RagdollModule"))
- local PlayerData = require(Data:WaitForChild("PlayerData"))
- local Anims = RepStorage:WaitForChild("Animations")
- local CombatModule = {}
- CombatModule.__index = CombatModule
- function CombatModule:M1(Char, Enemy)
- local Hum, HumRP = Char:WaitForChild("Humanoid"), Char:WaitForChild("HumanoidRootPart")
- local ClientFunctions = require(Char:WaitForChild("ClientFunctions"))
- local CurrentType = Char:GetAttribute("Type")
- local DataIndex = PlayerData.Stats[CurrentType]
- local DAMAGE = DataIndex.MeleeDamage
- local COMBO_SPEED = DataIndex.ComboWalkSpeed
- local WALK_SPEED = DataIndex.WalkSpeed
- local COMBO_RESET = 1.35
- local MAX_COMBO = 5
- local FINISH_COOLDOWN = 1
- local PUNCH_COOLDOWN = .45
- local STUN_VELOCITY = 13
- local FLING_VELOCITY = 70
- local FLING_DESPAWN = 1.25
- local RAGDOLL_TIME = 2
- local EFFECTS_DELAY = .25
- local PARTICLES_EMITTION = 15
- local HIT_PARTICLES = 1
- local Counter = 0
- local CombatMode = false
- local SpeedSet = false
- local CanAttack = true
- Char:SetAttribute("Attacking", true)
- Char:SetAttribute("MechanicDisable", true)
- Char:SetAttribute("Combo", Char:GetAttribute("Combo") + 1)
- ClientFunctions:Run(false)
- local Combo = Char:GetAttribute("Combo")
- local PunchAnim = Anims:WaitForChild("Basic"..Combo)
- local PunchSound = HumRP:WaitForChild("Swing")
- local PunchTrack = Hum:WaitForChild("Animator"):LoadAnimation(PunchAnim)
- PunchTrack:Play()
- task.delay(PunchTrack.Length - 0.05, function() PunchTrack:AdjustSpeed(0) task.wait(PUNCH_COOLDOWN) PunchTrack:Stop() end)
- PunchSound:Play()
- task.delay(EFFECTS_DELAY, function()
- Hum.WalkSpeed = COMBO_SPEED
- if Enemy then
- local EnemyHum, EnemyRP = Enemy:WaitForChild("Humanoid"), Enemy:WaitForChild("HumanoidRootPart")
- local HitSound = EnemyRP:WaitForChild("Smack")
- local Direction = (EnemyRP.Position - HumRP.Position)
- for i = 1, HIT_PARTICLES do
- EnemyRP:WaitForChild("HitParticle"..i):Emit(PARTICLES_EMITTION)
- end
- HitSound:Play()
- DamageController:DamageHumanoid(Enemy, {DAMAGE})
- if Combo == MAX_COMBO then
- RagdollModule:Ragdoll(Enemy, RAGDOLL_TIME)
- EnemyRP.AssemblyLinearVelocity = Direction * FLING_VELOCITY
- end
- end
- end)
- if Combo == MAX_COMBO then
- Hum.WalkSpeed = 0
- task.wait(FINISH_COOLDOWN)
- Char:SetAttribute("Combo", 0)
- Char:SetAttribute("MechanicDisable", false)
- Hum.WalkSpeed = WALK_SPEED
- CombatMode = true
- else
- task.wait(PUNCH_COOLDOWN)
- end
- Char:SetAttribute("Attacking", false)
- while not CombatMode do
- Counter += .01
- task.wait(.01)
- if Counter >= COMBO_RESET then
- Char:SetAttribute("Combo", 0)
- CombatMode = true
- SpeedSet = false
- elseif Counter >= (COMBO_RESET / 1.5) and not SpeedSet then
- warn("Walk Speed")
- Hum.WalkSpeed = WALK_SPEED
- SpeedSet = true
- Char:SetAttribute("MechanicDisable", false)
- end
- if Char:GetAttribute("Attacking") then
- Counter = 0
- CombatMode = true
- SpeedSet = false
- end
- end
- end
- function CombatModule:M2(Char, Enemy)
- print("Clicked M2")
- end
- return CombatModule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement