Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- author : Gixnly
- -- **THIS SCRIPT IS AN EVENT LISTENER FOR A SWORD**
- --- the formatting looks off cause of the way pastebin formats it, i dont actually format my code like how pastebin shows --
- local HeavySword = script.Parent.Parent
- local remotes = script.Parent.Parent.Remotes
- local modules = game.ServerStorage.Modules
- local AttackPhysics = require(modules:WaitForChild("AttackPhysics"))
- local combatDuration = 5
- local debris = game:GetService("Debris")
- local damage = 30
- local specialDamage = 80
- local blockStunTime = 2
- local stunTime = 0.8
- local ragTime = 2 -- timer
- local perfectBlockTime = 0.25
- local reTime = 5
- local recentHit = {}
- local bloodVFX = game.ReplicatedStorage:WaitForChild("VFX"):WaitForChild("BIO"):WaitForChild("E - Gushing") -- vfx
- local falseConditionsTable = {
- -- returns if the condition is true or false
- function(target) return target.Parent:GetAttribute("IFrame") == false end
- }
- local trueConditionsTable = {
- function(target) return target.Parent:GetAttribute("Player") == true end
- }
- local function FalseConditions(conditions,target) -- checks if any of the conditions here return false if it is false return true
- for index, conditionFunc in ipairs(conditions) do
- if not conditionFunc(target) then
- print(index.." not met")
- return true
- end
- end
- return false
- end
- local function TrueConditions(conditions,target) -- checks if any of the conditions here return false if it is false return false
- for index, conditionFunc in ipairs(conditions) do
- if not conditionFunc(target) then
- print(index.." not met")
- return false
- end
- end
- return true
- end
- remotes.ClientClickRemote.OnServerEvent:Connect(function(player,count,maxCombo) -- when a player clicks with the sword this fires
- local character = player.Character
- if character then -- checking if the character isn't nil
- character:SetAttribute("Attacking", true) -- pre defined attribute added in another script , used for checks
- local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
- -- Create the damage box
- local damageBox = Instance.new("Part")
- damageBox.CanTouch = true
- damageBox.Size = Vector3.new(5, 6, 5) -- Adjust the size as needed
- damageBox.Anchored = false
- damageBox.CanCollide = false
- damageBox.Transparency = 0.5
- damageBox.BrickColor = BrickColor.new("Bright red")
- damageBox.Name = "DamageBox"
- damageBox.Parent = game.Workspace
- damageBox.CFrame = humanoidRootPart.CFrame * CFrame.new(0,0,-2.5) -- Adjust the distance in front of the player
- damageBox.Touched:Connect(function(target)
- if target.Parent == nil then return end -- checking if the target has a parent, and if target exists
- if target == nil then return end
- local hum = target.Parent:FindFirstChildOfClass("Humanoid")
- if hum and count < maxCombo and FalseConditions(falseConditionsTable,target) == false and TrueConditions(trueConditionsTable,target) == true then -- checks if the current combo position is less than the maximum combo
- if target.Parent ~= player.Character and not table.find(recentHit, target.Parent) then
- local clone = bloodVFX.BloodVFX:Clone() -- create vfx
- clone.Parent = target.Parent:FindFirstChild("HumanoidRootPart") -- parent it to target
- task.delay(2,function() -- enable particle emitters
- for i, emitter in pairs(clone:GetDescendants()) do
- if emitter:IsA("ParticleEmitter") then
- emitter.Enabled = false
- end
- end
- task.wait(0.5)
- clone:Destroy() -- destroy vfx after 0.5 seconds
- end)
- character:SetAttribute("Combat", true)
- character:SetAttribute("CombatTimer", tick()) -- set attribute to tick, used to check if we can make combat false
- target.Parent:SetAttribute("Combat", true)
- target.Parent:SetAttribute("CombatTimer", tick()) -- same done for the target
- if hum.Health - damage <= 0 and hum.Health > 0 and not table.find(recentHit, target.Parent) and target.Parent:GetAttribute("Blocking") == false then -- if the next hit would kill them and they're not dead and they're not in the debounce table and if they arent blocking
- table.insert(recentHit, target.Parent) -- add them to the debounce (prevent multi hits)
- local gui = game.ReplicatedStorage.BillboardGui:Clone() -- clone a damage indicator gui
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-damage)
- task.delay(task.wait(), function()
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- player.leaderstats.kills.Value +=1 -- add to player kills
- AttackPhysics.RagdollCharacter(target.Parent) -- ragdoll the target via a module function
- target.Parent:SetAttribute("RagTimer", tick()) -- set a timer for their ragdoll, (prevent bugs)
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),20,10)
- hum:TakeDamage(damage)
- task.wait(reTime)
- table.remove(recentHit, table.find(recentHit, target.Parent)) -- remove from debounce after retime
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("RagTimer") >= reTime then -- if they weren't ragdolled again then unragdoll them
- AttackPhysics.Unragdoll(target.Parent)
- end
- return --- returning to stop the rest of the code from running
- elseif hum.Health - damage <= 0 and hum.Health > 0 and not table.find(recentHit, target.Parent) and target.Parent:GetAttribute("Blocking") == true then -- if the next hit kills them but they were blocking
- if target.Parent:GetAttribute("PerfectBlock") == true then -- check if the perfect block attribute was true when hit landed
- local tarPlayer = game.Players:GetPlayerFromCharacter(target.Parent) -- try to find a player obj from the target
- if tarPlayer then
- game.ReplicatedStorage.Remotes.PerfectBlockLanded:FireClient(tarPlayer) -- fires a remote to the client to stop the block anim
- end
- character:SetAttribute("Stun",true) -- stun the attacker
- character:SetAttribute("StunTimer",tick()) -- add a timer used for checks
- task.wait(blockStunTime)
- if tick() - character:GetAttribute("StunTimer") >= blockStunTime then -- if they weren't stunned again unstun them
- character:SetAttribute("Stun", false)
- character:SetAttribute("StunTimer",0)
- end
- return
- end
- local newDamage = damage * character:GetAttribute("BlockDamage") -- calculate the new damage to be applied
- table.insert(recentHit, target.Parent) -- add target to the debounce
- if hum.Health - newDamage <=0 and hum.Health > 0 then -- if the new damage would kill the target
- local gui = game.ReplicatedStorage.BillboardGui:Clone() -- clone damage indicator gui
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-newDamage)
- task.delay(task.wait(), function() -- function slowly makes the text rise and turn invisible
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- player.leaderstats.kills.Value +=1
- AttackPhysics.RagdollCharacter(target.Parent)
- target.Parent:SetAttribute("RagTimer", tick())
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),20,10)
- hum:TakeDamage(newDamage)
- task.wait(reTime)
- table.remove(recentHit, table.find(recentHit, target.Parent))
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("RagTimer") >= reTime then
- AttackPhysics.Unragdoll(target.Parent)
- end
- return -- returning so that the rest of the code wont run
- end
- hum:TakeDamage(newDamage) -- take new damage
- local gui = game.ReplicatedStorage.BillboardGui:Clone() -- clone damage indication gui
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-newDamage)
- task.delay(task.wait(), function()
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- character.Humanoid.Died:Connect(function() -- if the character dies find the target and unstun them
- if target.Parent then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- end)
- target.Parent:SetAttribute("Stun", true)
- target.Parent:SetAttribute("StunTimer", tick())
- target.Parent.Humanoid.AutoRotate = false
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),20,10)
- task.wait(stunTime)
- table.remove(recentHit, table.find(recentHit, target.Parent))
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("StunTimer") >= stunTime then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- return
- end
- if target.Parent:GetAttribute("Blocking") == false then -- now for the checks that run if they don't die from the damage
- table.insert(recentHit, target.Parent)
- hum:TakeDamage(damage)
- local gui = game.ReplicatedStorage.BillboardGui:Clone() -- clone damage indication gui
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-damage)
- task.delay(task.wait(), function()
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- character.Humanoid.Died:Connect(function() -- previously explained
- if target.Parent then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- end)
- target.Parent:SetAttribute("Stun", true)
- target.Parent:SetAttribute("StunTimer", tick())
- target.Parent.Humanoid.AutoRotate = false
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),20,10)
- task.wait(stunTime)
- table.remove(recentHit, table.find(recentHit, target.Parent))
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("StunTimer") >= stunTime then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- task.wait(combatDuration)
- if character == nil then return end
- if tick() - character:GetAttribute("CombatTimer") >= combatDuration then
- character:SetAttribute("CombatTimer", 0)
- character:SetAttribute("Combat", false)
- end
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("CombatTimer") >= combatDuration then
- target.Parent:SetAttribute("CombatTimer", 0)
- target.Parent:SetAttribute("Combat", false)
- end
- elseif target.Parent:GetAttribute("Blocking") == true then -- if they were blocking
- if target.Parent:GetAttribute("PerfectBlock") == true then -- check if perfect block was true
- local tarPlayer = game.Players:GetPlayerFromCharacter(target.Parent)
- if tarPlayer then
- game.ReplicatedStorage.Remotes.PerfectBlockLanded:FireClient(tarPlayer)
- end
- character:SetAttribute("Stun",true)
- character:SetAttribute("StunTimer",tick())
- task.wait(blockStunTime)
- if tick() - character:GetAttribute("StunTimer") >= blockStunTime then
- character:SetAttribute("Stun", false)
- character:SetAttribute("StunTimer",0)
- end
- return
- end
- local newDamage = damage * target.Parent:GetAttribute("BlockDamage") -- create new damage
- table.insert(recentHit, target.Parent)
- hum:TakeDamage(newDamage)
- local gui = game.ReplicatedStorage.BillboardGui:Clone()
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-newDamage)
- task.delay(task.wait(), function()
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- character.Humanoid.Died:Connect(function()
- if target.Parent then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- end)
- target.Parent:SetAttribute("Stun", true)
- target.Parent:SetAttribute("StunTimer", tick())
- target.Parent.Humanoid.AutoRotate = false
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),20,10)
- task.wait(stunTime)
- table.remove(recentHit, table.find(recentHit, target.Parent))
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("StunTimer") >= stunTime then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- task.wait(combatDuration)
- if character == nil then return end
- if tick() - character:GetAttribute("CombatTimer") >= combatDuration then
- character:SetAttribute("CombatTimer", 0)
- character:SetAttribute("Combat", false)
- end
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("CombatTimer") >= combatDuration then
- target.Parent:SetAttribute("CombatTimer", 0)
- target.Parent:SetAttribute("Combat", false)
- end
- end
- end
- elseif hum and count >= maxCombo and FalseConditions(falseConditionsTable,target) == false and TrueConditions(trueConditionsTable,target) == true then -- same as before but only if the combo count is the max combo
- if target.Parent ~= player.Character and not table.find(recentHit, target.Parent) then
- local clone = bloodVFX.BloodVFX:Clone()
- clone.Parent = target.Parent:FindFirstChild("HumanoidRootPart")
- task.delay(2,function()
- for i, emitter in pairs(clone:GetDescendants()) do
- if emitter:IsA("ParticleEmitter") then
- emitter.Enabled = false
- end
- end
- task.wait(0.5)
- clone:Destroy()
- end)
- game.Debris:AddItem(clone,2)
- character:SetAttribute("Combat", true)
- character:SetAttribute("CombatTimer", tick())
- target.Parent:SetAttribute("Combat", true)
- target.Parent:SetAttribute("CombatTimer", tick())
- if hum.Health - damage <= 0 and hum.Health > 0 and not table.find(recentHit, target.Parent) and target.Parent:GetAttribute("Blocking") == false then -- explained previously, all code after this is practically the same, but done this way incase any special thing happens when the combo's last hit is used.
- table.insert(recentHit, target.Parent)
- local gui = game.ReplicatedStorage.BillboardGui:Clone()
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-damage)
- task.delay(task.wait(), function()
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- player.leaderstats.kills.Value +=1
- AttackPhysics.RagdollCharacter(target.Parent)
- target.Parent:SetAttribute("RagTimer", tick())
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),20,10)
- hum:TakeDamage(damage)
- task.wait(reTime)
- table.remove(recentHit, table.find(recentHit, target.Parent))
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("RagTimer") >= reTime then
- AttackPhysics.Unragdoll(target.Parent)
- end
- return
- elseif hum.Health - damage <= 0 and hum.Health > 0 and not table.find(recentHit, target.Parent) and target.Parent:GetAttribute("Blocking") == true then
- if target.Parent:GetAttribute("PerfectBlock") == true then
- local tarPlayer = game.Players:GetPlayerFromCharacter(target.Parent)
- if tarPlayer then
- game.ReplicatedStorage.Remotes.PerfectBlockLanded:FireClient(tarPlayer)
- end
- character:SetAttribute("Stun",true)
- character:SetAttribute("StunTimer",tick())
- task.wait(blockStunTime)
- if tick() - character:GetAttribute("StunTimer") >= blockStunTime then
- character:SetAttribute("Stun", false)
- character:SetAttribute("StunTimer",0)
- end
- return
- end
- local newDamage = damage * character:GetAttribute("BlockDamage")
- table.insert(recentHit, target.Parent)
- if hum.Health - newDamage <=0 and hum.Health > 0 then
- local gui = game.ReplicatedStorage.BillboardGui:Clone()
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-newDamage)
- task.delay(task.wait(), function()
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- player.leaderstats.kills.Value +=1
- AttackPhysics.RagdollCharacter(target.Parent)
- target.Parent:SetAttribute("RagTimer", tick())
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),20,10)
- hum:TakeDamage(newDamage)
- task.wait(reTime)
- table.remove(recentHit, table.find(recentHit, target.Parent))
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("RagTimer") >= reTime then
- AttackPhysics.Unragdoll(target.Parent)
- end
- return
- end
- hum:TakeDamage(newDamage)
- local gui = game.ReplicatedStorage.BillboardGui:Clone()
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-newDamage)
- task.delay(task.wait(), function()
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- character.Humanoid.Died:Connect(function()
- if target.Parent then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- end)
- target.Parent:SetAttribute("Stun", true)
- target.Parent:SetAttribute("StunTimer", tick())
- target.Parent.Humanoid.AutoRotate = false
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),20,10)
- task.wait(stunTime)
- table.remove(recentHit, table.find(recentHit, target.Parent))
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("StunTimer") >= stunTime then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- return
- end
- if target.Parent:GetAttribute("Blocking") == false then
- table.insert(recentHit, target.Parent)
- hum:TakeDamage(damage)
- local gui = game.ReplicatedStorage.BillboardGui:Clone()
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-damage)
- task.delay(task.wait(), function()
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- character.Humanoid.Died:Connect(function()
- if target.Parent then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- end)
- target.Parent:SetAttribute("Stun", true)
- target.Parent:SetAttribute("StunTimer", tick())
- target.Parent.Humanoid.AutoRotate = false
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),20,10)
- task.wait(stunTime)
- table.remove(recentHit, table.find(recentHit, target.Parent))
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("StunTimer") >= stunTime then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- task.wait(combatDuration)
- if character == nil then return end
- if tick() - character:GetAttribute("CombatTimer") >= combatDuration then
- character:SetAttribute("CombatTimer", 0)
- character:SetAttribute("Combat", false)
- end
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("CombatTimer") >= combatDuration then
- target.Parent:SetAttribute("CombatTimer", 0)
- target.Parent:SetAttribute("Combat", false)
- end
- elseif target.Parent:GetAttribute("Blocking") == true then
- if target.Parent:GetAttribute("PerfectBlock") == true then
- local tarPlayer = game.Players:GetPlayerFromCharacter(target.Parent)
- if tarPlayer then
- game.ReplicatedStorage.Remotes.PerfectBlockLanded:FireClient(tarPlayer)
- end
- character:SetAttribute("Stun",true)
- character:SetAttribute("StunTimer",tick())
- task.wait(blockStunTime)
- if tick() - character:GetAttribute("StunTimer") >= blockStunTime then
- character:SetAttribute("Stun", false)
- character:SetAttribute("StunTimer",0)
- end
- return
- end
- local newDamage = damage * target.Parent:GetAttribute("BlockDamage")
- table.insert(recentHit, target.Parent)
- hum:TakeDamage(newDamage)
- local gui = game.ReplicatedStorage.BillboardGui:Clone()
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-newDamage)
- task.delay(task.wait(), function()
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- character.Humanoid.Died:Connect(function()
- if target.Parent then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- end)
- target.Parent:SetAttribute("Stun", true)
- target.Parent:SetAttribute("StunTimer", tick())
- target.Parent.Humanoid.AutoRotate = false
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),20,10)
- task.wait(stunTime)
- table.remove(recentHit, table.find(recentHit, target.Parent))
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("StunTimer") >= stunTime then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- task.wait(combatDuration)
- if character == nil then return end
- if tick() - character:GetAttribute("CombatTimer") >= combatDuration then
- character:SetAttribute("CombatTimer", 0)
- character:SetAttribute("Combat", false)
- end
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("CombatTimer") >= combatDuration then
- target.Parent:SetAttribute("CombatTimer", 0)
- target.Parent:SetAttribute("Combat", false)
- end
- end
- end
- else
- return
- end
- end)
- debris:AddItem(damageBox,0.1)
- else
- return
- end
- task.wait(0.5)
- character:SetAttribute("Attacking", false)
- end)
- remotes.ClientSpecialRemote.OnServerEvent:Connect(function(player) -- fires when a player uses a special move of the sword. Same logic as the client click remote only this has a few slight differences, such as damage box shape and knock back and checks.
- local character = player.Character
- if character then
- character:SetAttribute("Attacking", true)
- local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
- -- Create the damage box
- local damageBox = Instance.new("Part")
- damageBox.CanTouch = true
- damageBox.Size = Vector3.new(6, 15, 15) -- Adjust the size as needed
- damageBox.Shape = Enum.PartType.Cylinder
- damageBox.Anchored = false
- damageBox.CanCollide = false
- damageBox.Transparency = 0.5
- damageBox.BrickColor = BrickColor.new("Bright red")
- damageBox.Name = "DamageBox"
- damageBox.Parent = game.Workspace
- local rotation = CFrame.fromEulerAnglesXYZ(0, 0, math.rad(-90))
- damageBox.CFrame = humanoidRootPart.CFrame * rotation -- Adjust the distance in front of the player
- damageBox.Touched:Connect(function(target)
- if target.Parent == nil then return end
- if target == nil then return end
- local hum = target.Parent:FindFirstChildOfClass("Humanoid")
- if hum and TrueConditions(trueConditionsTable,target) == true then
- if target.Parent ~= player.Character and not table.find(recentHit, target.Parent) then
- local clone = bloodVFX.BloodVFX:Clone()
- clone.Parent = target.Parent:FindFirstChild("HumanoidRootPart")
- task.delay(2,function()
- for i, emitter in pairs(clone:GetDescendants()) do
- if emitter:IsA("ParticleEmitter") then
- emitter.Enabled = false
- end
- end
- task.wait(0.5)
- clone:Destroy()
- end)
- character:SetAttribute("Combat", true)
- character:SetAttribute("CombatTimer", tick())
- target.Parent:SetAttribute("Combat", true)
- target.Parent:SetAttribute("CombatTimer", tick())
- if hum.Health - specialDamage <= 0 and hum.Health > 0 and not table.find(recentHit, target.Parent) and target.Parent:GetAttribute("Blocking") == false then
- table.insert(recentHit, target.Parent)
- local gui = game.ReplicatedStorage.BillboardGui:Clone()
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-specialDamage)
- task.delay(task.wait(), function()
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- player.leaderstats.kills.Value +=1
- AttackPhysics.RagdollCharacter(target.Parent)
- target.Parent:SetAttribute("RagTimer", tick())
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),50,30)
- hum:TakeDamage(specialDamage)
- task.wait(reTime)
- table.remove(recentHit, table.find(recentHit, target.Parent))
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("RagTimer") >= reTime then
- AttackPhysics.Unragdoll(target.Parent)
- end
- return
- elseif hum.Health - specialDamage <= 0 and hum.Health > 0 and not table.find(recentHit, target.Parent) and target.Parent:GetAttribute("Blocking") == true then
- if target.Parent:GetAttribute("PerfectBlock") == true then
- local tarPlayer = game.Players:GetPlayerFromCharacter(target.Parent)
- if tarPlayer then
- game.ReplicatedStorage.Remotes.PerfectBlockLanded:FireClient(tarPlayer)
- end
- character:SetAttribute("Stun",true)
- character:SetAttribute("StunTimer",tick())
- task.wait(blockStunTime)
- if tick() - character:GetAttribute("StunTimer") >= blockStunTime then
- character:SetAttribute("Stun", false)
- character:SetAttribute("StunTimer",0)
- end
- return
- end
- local newDamage = specialDamage * character:GetAttribute("BlockDamage")
- table.insert(recentHit, target.Parent)
- if hum.Health - newDamage <=0 and hum.Health > 0 then
- local gui = game.ReplicatedStorage.BillboardGui:Clone()
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-newDamage)
- task.delay(task.wait(), function()
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- player.leaderstats.kills.Value +=1
- AttackPhysics.RagdollCharacter(target.Parent)
- target.Parent:SetAttribute("RagTimer", tick())
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),50,30)
- hum:TakeDamage(newDamage)
- task.wait(reTime)
- table.remove(recentHit, table.find(recentHit, target.Parent))
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("RagTimer") >= reTime then
- AttackPhysics.Unragdoll(target.Parent)
- end
- return
- end
- hum:TakeDamage(newDamage)
- local gui = game.ReplicatedStorage.BillboardGui:Clone()
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-newDamage)
- task.delay(task.wait(), function()
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- character.Humanoid.Died:Connect(function()
- if target.Parent then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- end)
- target.Parent:SetAttribute("Stun", true)
- target.Parent:SetAttribute("StunTimer", tick())
- target.Parent.Humanoid.AutoRotate = false
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),50,30)
- task.wait(stunTime)
- table.remove(recentHit, table.find(recentHit, target.Parent))
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("StunTimer") >= stunTime then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- return
- end
- if target.Parent:GetAttribute("Blocking") == false then
- table.insert(recentHit, target.Parent)
- hum:TakeDamage(specialDamage)
- local gui = game.ReplicatedStorage.BillboardGui:Clone()
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-specialDamage)
- task.delay(task.wait(), function()
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- character.Humanoid.Died:Connect(function()
- if target.Parent then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- end)
- target.Parent:SetAttribute("Stun", true)
- target.Parent:SetAttribute("StunTimer", tick())
- target.Parent.Humanoid.AutoRotate = false
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),50,30)
- task.wait(stunTime)
- table.remove(recentHit, table.find(recentHit, target.Parent))
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("StunTimer") >= stunTime then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- task.wait(combatDuration)
- if character == nil then return end
- if tick() - character:GetAttribute("CombatTimer") >= combatDuration then
- character:SetAttribute("CombatTimer", 0)
- character:SetAttribute("Combat", false)
- end
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("CombatTimer") >= combatDuration then
- target.Parent:SetAttribute("CombatTimer", 0)
- target.Parent:SetAttribute("Combat", false)
- end
- elseif target.Parent:GetAttribute("Blocking") == true then
- if target.Parent:GetAttribute("PerfectBlock") == true then
- local tarPlayer = game.Players:GetPlayerFromCharacter(target.Parent)
- if tarPlayer then
- game.ReplicatedStorage.Remotes.PerfectBlockLanded:FireClient(tarPlayer)
- end
- character:SetAttribute("Stun",true)
- character:SetAttribute("StunTimer",tick())
- task.wait(blockStunTime)
- if tick() - character:GetAttribute("StunTimer") >= blockStunTime then
- character:SetAttribute("Stun", false)
- character:SetAttribute("StunTimer",0)
- end
- return
- end
- local newDamage = specialDamage * target.Parent:GetAttribute("BlockDamage")
- table.insert(recentHit, target.Parent)
- hum:TakeDamage(newDamage)
- local gui = game.ReplicatedStorage.BillboardGui:Clone()
- debris:AddItem(gui,1)
- gui.Parent = target.Parent
- gui.DamageIndicate.Text = tostring(-newDamage)
- task.delay(task.wait(), function()
- for i = 0, 10 , .01 do
- if gui == nil then return end
- gui.ExtentsOffset = gui.ExtentsOffset + Vector3.new(0,0.01,0)
- if gui:FindFirstChild("DamageIndicate") then
- gui.DamageIndicate.TextTransparency += 0.05
- end
- task.wait(0.01)
- end
- end)
- character.Humanoid.Died:Connect(function()
- if target.Parent then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- end)
- target.Parent:SetAttribute("Stun", true)
- target.Parent:SetAttribute("StunTimer", tick())
- target.Parent.Humanoid.AutoRotate = false
- AttackPhysics.SpecificKB(target.Parent, character:WaitForChild("HumanoidRootPart"),50,30)
- task.wait(stunTime)
- table.remove(recentHit, table.find(recentHit, target.Parent))
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("StunTimer") >= stunTime then
- target.Parent:SetAttribute("Stun", false)
- target.Parent:SetAttribute("StunTimer",0)
- target.Parent.Humanoid.AutoRotate = true
- end
- task.wait(combatDuration)
- if character == nil then return end
- if tick() - character:GetAttribute("CombatTimer") >= combatDuration then
- character:SetAttribute("CombatTimer", 0)
- character:SetAttribute("Combat", false)
- end
- if target.Parent == nil then return end
- if tick() - target.Parent:GetAttribute("CombatTimer") >= combatDuration then
- target.Parent:SetAttribute("CombatTimer", 0)
- target.Parent:SetAttribute("Combat", false)
- end
- end
- else
- return
- end
- else
- return
- end
- end)
- else
- return
- end
- end)
- remotes.ClientBlockRemote.OnServerEvent:Connect(function(player, blockCd) -- fires when the player presses the block button
- local character = player.Character
- if character then
- character:SetAttribute("Blocking",true) -- set blocking to true
- task.spawn(function() -- sets perfect block to true temporarily
- character:SetAttribute("PerfectBlock", true)
- task.wait(perfectBlockTime)
- character:SetAttribute("PerfectBlock", false)
- end)
- task.wait(blockCd) -- set blocking back to false after a cool down
- if character:GetAttribute("Blocking") == true then
- character:SetAttribute("Blocking",false)
- remotes.ClientBlockRemote:FireClient(player)
- end
- else
- return
- end
- end)
- remotes.AdjustSpeedRemote.OnServerEvent:Connect(function(player, slowWholeNumber, waitTime) -- slows speed when the player uses a move
- local character = player.Character
- if character then
- local currentSpeed = character:GetAttribute("Speed")
- if slowWholeNumber > 0 then
- local adjustment = currentSpeed - (currentSpeed / slowWholeNumber)
- remotes.SpeedReduced:FireClient(player,currentSpeed) -- fires client to let them know of the speed decrease, used to re add speed if a perfect block is performed
- if character:GetAttribute("Speed") + adjustment > 0 then -- if we don't slow them too much
- character:SetAttribute("Speed", character:GetAttribute("Speed") - adjustment)
- task.wait(waitTime) -- cool down
- if character:GetAttribute("Speed") < currentSpeed then -- if the speed is still reduced (if a perfect block wasn't landed)
- character:SetAttribute("Speed", character:GetAttribute("Speed") + adjustment)
- end
- else
- return
- end
- else
- return
- end
- else
- return
- end
- end)
Advertisement
Advertisement