game.ReplicatedStorage.remotes.PunchEvent.OnServerEvent:Connect(function(plr,punchcount,Mouse)
local Char = plr.Character or plr.CharacterAdded:Wait()
local Cooldown = false
local HitBoxPart
local Ready = true
local function HitBox()
HitBoxPart = Instance.new("Part",workspace)
HitBoxPart.CanCollide = false
HitBoxPart.Name = "HitBox"
HitBoxPart.Size = Vector3.new(6, 5.1, 6)
HitBoxPart.Transparency = 1
HitBoxPart.Anchored = false
HitBoxPart.CFrame = Char.HumanoidRootPart.CFrame * CFrame.new(0,0,-1)
local weld = Instance.new("WeldConstraint")
weld.Part0 = HitBoxPart
weld.Part1 = Char.HumanoidRootPart
weld.Parent = HitBoxPart
HitBoxPart.Touched:Connect(function(h)
if h.Parent:FindFirstChild('Humanoid') and h.Parent.Name ~= plr.Name and Cooldown == false then
-- // Combat Effects
local ehrp = h.Parent:FindFirstChild("HumanoidRootPart")
if ehrp and Ready == true and punchcount == 3 then
local shockX = math.random(-180,180)
local Shock = PunchShock:Clone()
Shock.CFrame = ehrp.CFrame * CFrame.Angles(0,shockX,0)
Shock.Parent = workspace
spawn(function()
for i = 1,50 do wait()
Shock.Size = Shock.Size + Vector3.new(1.5,1.5,1.5)
Shock.Transparency = Shock.Transparency + 0.05
end
end)
Ready = false
Derbis:AddItem(Shock,0.6)
local HitBV = Instance.new("BodyVelocity")
HitBV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
HitBV.P = 100
HitBV.Velocity = Char.HumanoidRootPart.CFrame.lookVector*45
HitBV.Parent = ehrp
Derbis:AddItem(HitBV,1)
end
-------------------------------
if punchcount < 3 then
local X = math.random(-180,180)
local Y = math.random(-180,180)
local Z = math.random(-180,180)
spawn(function()
local HBeam = HitBeam:Clone()
HBeam.Parent = workspace
HitBeam.CFrame = CFrame.new((ehrp.CFrame * CFrame.new(0, 0, 0)).Position, Mouse.Position) * CFrame.Angles(0, math.rad(0), 0)
spawn(function()
for i = 1,50 do wait()
HBeam.Size = HBeam.Size + Vector3.new(0.15,0.15,0.5)
HBeam.Transparency = HBeam.Transparency + 0.1
end
end)
Derbis:AddItem(HBeam,1.2)
end)
end
-- // ---------------
local Enemy = h.Parent.Humanoid
Enemy:TakeDamage(1)
spawn(function()
Enemy.WalkSpeed = 0
wait(5)
Enemy.WalkSpeed = 16
end)
if game.Players:FindFirstChild(h.Parent.Name) then
wait(0)
Knockback:FireClient(game.Players:FindFirstChild(h.Parent.Name))
end
Cooldown = true
wait(0.5)
Cooldown = false
end
end)
Derbis:AddItem(HitBoxPart,0.2)
end
HitBox()
end)
Here is the result of the code:
https://i.gyazo.com/663e0f4f1d9c1572cf86a2d42be41f6b.mp4
I am not an expert when it comes to combat systems and these kinds of stuff so is there anything you would improve or change in the script?