Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local event = game:GetService("ReplicatedStorage").hit
- local enemyevent = game:GetService("ServerScriptService").enemyhit
- local dodge = game:GetService("ReplicatedStorage").dodge
- local parry = game:GetService("ReplicatedStorage").parry
- local sfx = game:GetService("ReplicatedStorage").sfx
- local ts = require(game:GetService("ReplicatedStorage").Tween)
- local DamageUI = require(script.Parent.DamageBillboardCreator)
- local already = {}
- local playershit = {}
- local playercanm1 = {}
- game.Players.PlayerAdded:Connect(function(plr)
- playercanm1[plr] = true
- end)
- local function calculate(AttackType, Player, Enemy)
- if AttackType == 1 then
- return (Player.ATK * (1 + (Player.LVL ^ 0.8) / 10) - (Enemy.DEF * 0.5) + 200) * 0.95 * 0.55 + Player.PEN
- elseif AttackType == 2 then
- return (Player.ATK * (1 + (Player.LVL ^ 0.8) / 10) - (Enemy.DEF * 0.5) + 200) * 0.95 * 0.55 * 1.75 + 500 + Player.PEN
- elseif AttackType == 3 then
- return (Player.ATK * (1 + (Player.LVL ^ 0.5) / 5) - (Enemy.DEF * 0.5)) * 3 + 2000 + Player.PEN
- elseif AttackType == 4 then
- return Player.GLE - Enemy.GLR
- elseif AttackType == 5 then
- return ((Player.GLM ^ 3 * Player.LVL ^ 3.2 * 0.1) + (Player.ATK * Player.LVL ^ 1.5 * 0.1)) * 0.3 + 1000 + Player.PEN
- end
- end
- local function enemy(Player, Enemy)
- return (Enemy.ATK * (1 + (Player.LVL ^ 0.5))) / (1 + (Player.DEF / 50)) * 0.2
- end
- local regens = {}
- local function regenparry(plr:Player)
- if regens[plr] then return end
- regens[plr] = true
- while plr:GetAttribute("ParryStamina") ~= 6 do
- for i = 1, 8 do
- ts.wait(1)
- plr:SetAttribute("ParryCountdown", plr:GetAttribute("ParryCountdown") - 1)
- end
- plr:SetAttribute("ParryStamina", plr:GetAttribute("ParryStamina") + 1)
- plr:SetAttribute("ParryCountdown", 8)
- end
- regens[plr] = false
- end
- event.OnServerEvent:Connect(function(plr, AttackType)
- if not playercanm1[plr] then return end
- if plr:GetAttribute("Parrying") then return end
- if plr:GetAttribute("Invincible") then return end
- local hitbox = Instance.new("Part", workspace)
- hitbox.BrickColor = BrickColor.new("Really red")
- hitbox.CastShadow = false
- hitbox.Material = Enum.Material.Neon
- hitbox.CanCollide = false
- hitbox.Transparency = 0.75
- hitbox.Massless = true
- local weld = Instance.new("Weld", plr.Character:WaitForChild("HumanoidRootPart"))
- weld.Part0 = plr.Character:WaitForChild("HumanoidRootPart")
- weld.Part1 = hitbox
- local knockback
- if AttackType == 1 then
- hitbox.Size = Vector3.new(5, 5, 5)
- knockback = 10
- elseif AttackType == 2 then
- hitbox.Size = Vector3.new(6, 6, 7)
- knockback = 15
- end
- weld.C1 = CFrame.new(0, 0, 3)
- task.wait()
- weld:Destroy()
- hitbox.Anchored = true
- hitbox.Touched:Connect(function(hit)
- local enemy = hit:FindFirstAncestorWhichIsA("Model")
- if not enemy then return end
- if enemy == plr.Character then return end
- if not enemy.Name:match("EnemyEntity") then return end
- if already[enemy] then return end
- local humanoid = enemy:FindFirstChild("Humanoid")
- if not humanoid or humanoid.Health <= 0 then return end
- already[enemy] = true
- local direction = humanoid.MoveDirection
- local force = Instance.new("LinearVelocity", enemy:WaitForChild("HumanoidRootPart"))
- force.MaxForce = math.huge
- force.Attachment0 = enemy:WaitForChild("HumanoidRootPart").RootAttachment
- force.VectorVelocity = plr.Character.HumanoidRootPart.CFrame.LookVector * knockback
- dodge:FireClient(plr)
- local tweener = Instance.new("Vector3Value", enemy:WaitForChild("HumanoidRootPart"))
- tweener.Value = force.VectorVelocity
- local force_tween = ts.tween(tweener, {
- Value = Vector3.new(0, 0, 0)
- }, {
- duration = 1,
- style = "Exponential",
- direction = "Out"
- })
- tweener:GetPropertyChangedSignal("Value"):Connect(function()
- force.VectorVelocity = tweener.Value
- if force.VectorVelocity.Magnitude <= 0.5 then
- force:Destroy()
- end
- end)
- local Player = {
- LVL = plr:GetAttribute("LVL"),
- ATK = plr:GetAttribute("ATK"),
- DEF = plr:GetAttribute("DEF"),
- STN = plr:GetAttribute("STN"),
- CRR = plr:GetAttribute("CRR"),
- CRD = plr:GetAttribute("CRD"),
- PEN = plr:GetAttribute("PEN"),
- GLE = plr:GetAttribute("GLE"),
- GLM = plr:GetAttribute("GLM"),
- }
- local Enemy = {
- ATK = enemy:GetAttribute("ATK"),
- DEF = enemy:GetAttribute("DEF"),
- GLR = enemy:GetAttribute("GLR")
- }
- local dmg = math.round(calculate(AttackType, Player, Enemy))
- hit.Parent.Humanoid.Health -= dmg
- local ui = DamageUI.create(hit.Parent, dmg)
- ui.Parent = hit.Parent
- local tween_pos = ts.tween(ui, {
- StudsOffsetWorldSpace = Vector3.new(0, 1, 0)
- }, {
- duration = 1,
- style = "Exponential",
- direction = "Out"
- })
- local tween_num = ts.tween(ui.num, {
- TextTransparency = 1
- }, {
- duration = 1,
- style = "Quad",
- direction = "InOut"
- })
- local tween_stroke = ts.tween(ui.num.UIStroke, {
- Transparency = 1
- }, {
- duration = 1,
- style = "Quad",
- direction = "InOut"
- })
- ts.wait(1)
- ui:Destroy()
- end)
- ts.wait(0.2)
- hitbox:Destroy()
- already = {}
- playercanm1[plr] = false
- ts.wait(0.5)
- playercanm1[plr] = true
- end)
- enemyevent.Event:Connect(function(attacker, move)
- local hitbox = Instance.new("Part", workspace)
- hitbox.BrickColor = BrickColor.new("Really red")
- hitbox.CastShadow = false
- hitbox.Material = Enum.Material.Neon
- hitbox.CanCollide = false
- hitbox.Transparency = 0.75
- hitbox.Massless = true
- local weld = Instance.new("Weld", attacker:WaitForChild("HumanoidRootPart"))
- weld.Part0 = attacker:WaitForChild("HumanoidRootPart")
- weld.Part1 = hitbox
- if move == 1 then
- hitbox.Size = Vector3.new(5, 5, 5)
- elseif move == 2 then
- hitbox.Size = Vector3.new(6, 6, 7)
- end
- weld.C1 = CFrame.new(0, 0, 3)
- task.wait()
- weld:Destroy()
- hitbox.Anchored = true
- hitbox.Touched:Connect(function(hit)
- local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
- if not plr then return end
- if hit.Parent == attacker then return end
- if playershit[plr] then return end
- local humanoid = plr.Character:FindFirstChild("Humanoid")
- if not humanoid or humanoid.Health <= 0 then return end
- playershit[plr] = true
- if plr:GetAttribute("Invincible") then
- dodge:FireClient(plr)
- return
- end
- local Player = {
- LVL = plr:GetAttribute("LVL"),
- ATK = plr:GetAttribute("ATK"),
- DEF = plr:GetAttribute("DEF"),
- STN = plr:GetAttribute("STN"),
- CRR = plr:GetAttribute("CRR"),
- CRD = plr:GetAttribute("CRD"),
- PEN = plr:GetAttribute("PEN"),
- GLE = plr:GetAttribute("GLE"),
- GLM = plr:GetAttribute("GLM"),
- }
- local Attacker = {
- ATK = attacker:GetAttribute("ATK"),
- DEF = attacker:GetAttribute("DEF"),
- GLR = attacker:GetAttribute("GLR")
- }
- if plr:GetAttribute("Parrying") and move ~= 2 then
- if plr:GetAttribute("ParryStamina") > 0 then
- local time = plr:GetAttribute("ParryStartTime")
- if time and (os.clock() - time) <= 0.1 then
- sfx:FireAllClients(plr.Character.Name, "parry")
- local reflecttxt = DamageUI.create(attacker, "REFLECTED!")
- reflecttxt.Parent = attacker
- reflecttxt.StudsOffsetWorldSpace = Vector3.new(0, 1.5, 0)
- local tween_pos = ts.tween(reflecttxt, {
- StudsOffsetWorldSpace = Vector3.new(0, 2, 0)
- }, {
- duration = 1,
- style = "Exponential",
- direction = "Out"
- })
- local tween_num = ts.tween(reflecttxt.num, {
- TextTransparency = 1
- }, {
- duration = 1,
- style = "Quad",
- direction = "InOut"
- })
- local tween_stroke = ts.tween(reflecttxt.num.UIStroke, {
- Transparency = 1
- }, {
- duration = 1,
- style = "Quad",
- direction = "InOut"
- })
- local dmg = math.round(enemy(Player, Attacker) * 0.75)
- attacker.Humanoid.Health -= dmg
- local ui = DamageUI.create(attacker, dmg)
- ui.Parent = attacker
- local tween_pos = ts.tween(ui, {
- StudsOffsetWorldSpace = Vector3.new(0, 1, 0)
- }, {
- duration = 1,
- style = "Exponential",
- direction = "Out"
- })
- local tween_num = ts.tween(ui.num, {
- TextTransparency = 1
- }, {
- duration = 1,
- style = "Quad",
- direction = "InOut"
- })
- local tween_stroke = ts.tween(ui.num.UIStroke, {
- Transparency = 1
- }, {
- duration = 1,
- style = "Quad",
- direction = "InOut"
- })
- parry:FireClient(plr)
- ts.wait(1)
- reflecttxt:Destroy()
- ui:Destroy()
- return
- else
- sfx:FireAllClients(plr.Character.Name, "parry")
- parry:FireClient(plr)
- plr:SetAttribute("ParryStamina", plr:GetAttribute("ParryStamina") - 1)
- regenparry(plr)
- return
- end
- else
- sfx:FireAllClients(plr.Character.Name, "break")
- local dmg = math.round(enemy(Player, Attacker) * 0.5)
- hit.Parent.Humanoid.Health -= dmg
- local ui = DamageUI.create(hit.Parent, dmg)
- ui.Parent = hit.Parent
- local tween_pos = ts.tween(ui, {
- StudsOffsetWorldSpace = Vector3.new(0, 1, 0)
- }, {
- duration = 1,
- style = "Exponential",
- direction = "Out"
- })
- local tween_num = ts.tween(ui.num, {
- TextTransparency = 1
- }, {
- duration = 1,
- style = "Quad",
- direction = "InOut"
- })
- local tween_stroke = ts.tween(ui.num.UIStroke, {
- Transparency = 1
- }, {
- duration = 1,
- style = "Quad",
- direction = "InOut"
- })
- local breaktxt = DamageUI.create(hit.Parent, "BREAK!")
- breaktxt.Parent = hit.Parent
- breaktxt.StudsOffsetWorldSpace = Vector3.new(0, 1.5, 0)
- local tween_pos = ts.tween(breaktxt, {
- StudsOffsetWorldSpace = Vector3.new(0, 2, 0)
- }, {
- duration = 1,
- style = "Exponential",
- direction = "Out"
- })
- local tween_num = ts.tween(breaktxt.num, {
- TextTransparency = 1
- }, {
- duration = 1,
- style = "Quad",
- direction = "InOut"
- })
- local tween_stroke = ts.tween(breaktxt.num.UIStroke, {
- Transparency = 1
- }, {
- duration = 1,
- style = "Quad",
- direction = "InOut"
- })
- local chr = plr.Character
- local direction = chr:FindFirstChildOfClass("Humanoid").MoveDirection
- local force = Instance.new("LinearVelocity", chr:WaitForChild("HumanoidRootPart"))
- force.MaxForce = math.huge
- force.Attachment0 = chr:WaitForChild("HumanoidRootPart").RootAttachment
- force.VectorVelocity = (direction ~= Vector3.zero and direction or -chr.HumanoidRootPart.CFrame.LookVector) * 10
- local tweener = Instance.new("Vector3Value", enemy:WaitForChild("HumanoidRootPart"))
- tweener.Value = force.VectorVelocity
- local force_tween = ts.tween(tweener, {
- Value = Vector3.new(0, 0, 0)
- }, {
- duration = 0.75,
- style = "Exponential",
- direction = "Out"
- })
- tweener:GetPropertyChangedSignal("Value"):Connect(function()
- force.VectorVelocity = tweener.Value
- if force.VectorVelocity.Magnitude <= 0.5 then
- force:Destroy()
- end
- end)
- ts.wait(1)
- ui:Destroy()
- breaktxt:Destroy()
- return
- end
- end
- local dmg = math.round(enemy(Player, Attacker))
- hit.Parent.Humanoid.Health -= dmg
- local ui = DamageUI.create(hit.Parent, dmg)
- ui.Parent = hit.Parent
- ui.num.TextColor3 = Color3.fromRGB(255, 0, 0)
- local tween_pos = ts.tween(ui, {
- StudsOffsetWorldSpace = Vector3.new(0, 1, 0)
- }, {
- duration = 1,
- style = "Exponential",
- direction = "Out"
- })
- local tween_num = ts.tween(ui.num, {
- TextTransparency = 1
- }, {
- duration = 1,
- style = "Quad",
- direction = "InOut"
- })
- local tween_stroke = ts.tween(ui.num.UIStroke, {
- Transparency = 1
- }, {
- duration = 1,
- style = "Quad",
- direction = "InOut"
- })
- ts.wait(1)
- ui:Destroy()
- end)
- ts.wait(0.2)
- hitbox:Destroy()
- playershit = {}
- end)
Advertisement
Add Comment
Please, Sign In to add comment