Feedback on melee system, [AS MUCH CONSTRUCTIVE CRITISZM AS POSSIBLE]


--7891359828
--7891483908
local playerr = script.Parent.Parent.Parent
local Player = script.Parent.Parent.Parent
Player.CharacterAdded:Wait()

local Character = script.Parent.Parent.Parent.Character
local dmgpoint1 = Instance.new("Attachment")
dmgpoint1.Position = Vector3.new(0, -1.598, 0)
dmgpoint1.Name = "DmgPoint"
dmgpoint1.Parent = Character["Right Arm"]

local dmgpoint2 = Instance.new("Attachment")
dmgpoint2.Position = Vector3.new(0, -1.598, 0)
dmgpoint2.Name = "DmgPoint"
dmgpoint2.Parent = Character["Left Arm"]

local dmgpoint3 = Instance.new("Attachment")
dmgpoint3.Position = Vector3.new(0, -1.598, -0.662)
dmgpoint3.Name = "DmgPoint"
dmgpoint3.Parent = Character["Left Leg"]

local dmgpoint4 = Instance.new("Attachment")
dmgpoint4.Position = Vector3.new(0, -1.598, -0.662)
dmgpoint4.Name = "DmgPoint"
dmgpoint4.Parent = Character["Right Leg"]

local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(0, 0, -2.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(0, 0, -3.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(0, 0, -4.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(0, 0, -5.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart

local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(0, -2, -2.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(0, -2, -3.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(0, -2, -4.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(0, -2, -5.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart

local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(0, 3, -2.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(0, 3, -3.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(0, 3, -4.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(0, 3, -5.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart

----
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(2, 0, -2.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(2, 0, -3.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(2, 0, -4.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(2, 0, -5.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart

local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(2, -2, -2.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(2, -2, -3.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(2, -2, -4.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(2, -2, -5.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart

local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(2, 3, -2.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(2, 3, -3.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(2, 3, -4.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(2, 3, -5.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
--
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(-2, 0, -2.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(-2, 0, -3.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(-2, 0, -4.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(-2, 0, -5.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart

local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(-2, -2, -2.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(-2, -2, -3.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(-2, -2, -4.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(-2, -2, -5.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart

local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(-2, 3, -2.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(-2, 3, -3.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(-2, 3, -4.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
local dmgpoint5 = Instance.new("Attachment")
dmgpoint5.Position = Vector3.new(-2, 3, -5.273)
dmgpoint5.Name = "DmgPoint"
dmgpoint5.Parent = Character.HumanoidRootPart
--7909980633

local raycastHitbox = require(game:GetService("ReplicatedStorage").RaycastHitboxV4)
local Hitbox = raycastHitbox.new(Character)
print(Character.Name)
local Damage = 5
local player = script.Parent.Parent.Parent.Character
local humanoid = player:WaitForChild("Humanoid")
wait(1)
local idleanim = Instance.new("Animation")
idleanim.AnimationId = "rbxassetid://7915926344"
local idletrack = humanoid:LoadAnimation(idleanim)
local attackanim = Instance.new("Animation")
attackanim.AnimationId = "rbxassetid://7909632017"
local attacktrack = humanoid:LoadAnimation(attackanim)
local attackanim2 = Instance.new("Animation")
attackanim2.AnimationId = "rbxassetid://7909707492"
local attacktrack2 = humanoid:LoadAnimation(attackanim2)
local attackanim3 = Instance.new("Animation")
attackanim3.AnimationId = "rbxassetid://7909669676"
local waittime = 0.5
local db = false
local combo = Instance.new("IntValue")
combo.Name = "Combo"
combo.Value = 0
combo.Parent = player
local hasHit = Instance.new("BoolValue")
hasHit.Name = "HasHit"
hasHit.Value = false
hasHit.Parent = player
local attacktrack3 = humanoid:LoadAnimation(attackanim3)
local combodone = false

local kickanim = Instance.new("Animation")
kickanim.AnimationId = "rbxassetid://7917146259"
kickanim.Parent = script.Parent
local kickanimtrack = humanoid:LoadAnimation(kickanim)

local kickanim2 = Instance.new("Animation")
kickanim2.AnimationId = "rbxassetid://7917188094"
kickanim2.Parent = script.Parent
local kickanimtrack2 = humanoid:LoadAnimation(kickanim2)

local blockanim = Instance.new("Animation")
blockanim.AnimationId = "rbxassetid://7909945666"
blockanim.Parent = script.Parent
local blockanimtrack = humanoid:LoadAnimation(blockanim)

local blockhit = Instance.new("Animation")
blockhit.AnimationId = "rbxassetid://7919426898"
blockhit.Parent = script.Parent
local blochitanimtrack = humanoid:LoadAnimation(blockhit)

local hp = Instance.new("Animation")
hp.AnimationId = "rbxassetid://7917758532"
hp.Parent = script.Parent
local hptrack = humanoid:LoadAnimation(hp)

--7919154517

local brek = Instance.new("Animation")
brek.AnimationId = "rbxassetid://7920337242"
brek.Parent = script.Parent

--7917758532
local IsBlocking = Character.IsBlocking
local stun = Character.stun

script.Parent.RemoteEvent.OnServerEvent:Connect(function()
	if stun.Value == false then
		blockanimtrack:Play()
		humanoid.WalkSpeed = 4
		IsBlocking.Value = true 
	end
end)

script.Parent.RE.OnServerEvent:Connect(function()
	if stun.Value == false then
		blockanimtrack:Stop()
		humanoid.WalkSpeed = 16
		IsBlocking.Value = false
	end
end)

task.spawn(function()
	while task.wait(4) do
		if hasHit.Value == false then
			combo.Value = 0
			print("yes")
			db = true
			wait(1)
			db = false
		else 
			combo.Value = combo.Value
		end
	end
end)
local waittime = 0.5

script.Parent.Activated:Connect(function()
	if stun.Value == false then
		if IsBlocking.Value == false then
			if db == false then
				if combodone == false then
					local body = Instance.new("BodyVelocity")
					body.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
					body.Velocity = Character.HumanoidRootPart.CFrame.LookVector * 2
					body.Parent = Character.HumanoidRootPart
					hasHit.Value = true
					Character.Humanoid.WalkSpeed = 4
					db = true
					if combodone == false then
						if combo.Value < 5 then
							Hitbox:HitStart() 
						end
					end
					Hitbox.OnHit:Connect(function(hit, humanoid)
						if humanoid.Parent.Name ~= script.Parent.Parent.Name then
							if humanoid.Parent.IsBlocking.Value == false then

								humanoid:TakeDamage(Damage)
								humanoid.Parent.HumanoidRootPart.Anchored = true
								humanoid.Parent.Fists.Enabled = false
								
								humanoid.Parent.HumanoidRootPart.Orientation = Character.HumanoidRootPart.Orientation + Vector3.new(0,180,0)
								if combo.Value < 5 then
									script.Parent.punch:Play()
								end
								humanoid.Parent.stun.Value = true
								if combo.Value == 5 then
									wait(0.15)
									script.Parent.uppercut:Play()
									humanoid:ChangeState(Enum.HumanoidStateType.Ragdoll)

									humanoid.Parent.HumanoidRootPart.Anchored = false
									local vel = Instance.new("BodyVelocity")
									vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
									vel.Velocity = Character.HumanoidRootPart.CFrame.LookVector * 30
									vel.Name = "vel"
									vel.Parent = hit
									wait(0.5)
									waittime = 0
									vel:Destroy()
									
								end
								wait(waittime)
								waittime = 0.5
								
								humanoid.Parent.HumanoidRootPart.Anchored = false
								humanoid.Parent.Fists.Enabled = true
								
								humanoid.Parent.stun.Value = false
								if humanoid.Health <= 0 then
									playerr.leaderstats.Kills.Value += 1
								end
							
							else
								local blockhitanimtrack = humanoid:LoadAnimation(blockhit)
								blockhitanimtrack:Play()
								if humanoid.Parent.IsBlocking == true then
									print("he")
								end
							end
						end
					end)
					if combo.Value == 0 then
						attacktrack:Play()
						combo.Value += 1
					elseif combo.Value == 1 then
						attacktrack2:Play()
						combo.Value += 1
					elseif combo.Value == 2 then
						kickanimtrack:Play()
						combo.Value += 1

					elseif combo.Value == 3 then
						kickanimtrack2:Play()
						combo.Value += 1

					elseif combo.Value == 4 then
						attacktrack3:Play()
						combo.Value += 1
						wait(0.2)
					elseif combo.Value == 5 then
						combodone = true
						combo.Value = 0
						Character.Humanoid.WalkSpeed = 16
						wait(0.2)
						Hitbox:HitStop()
						wait(0.5)
						combodone = false
					end
					wait(0.3)
					body:Destroy()
					Hitbox:HitStop()
					wait(0.1)
					if IsBlocking.Value == false then
						Character.Humanoid.WalkSpeed = 16 
					end
					db = false
					wait(1)
					hasHit.Value = false
				end
			end
		end
	end
end)



script.Parent.Equipped:Connect(function()
	idletrack:Play()
end)

script.Parent.Unequipped:Connect(function()
	idletrack:Stop()
end)
local spdb = false

script.Parent.sp.OnServerEvent:Connect(function()
	if spdb == false and IsBlocking.Value == false and stun.Value == false and hasHit.Value == false then
		db = true
		spdb = true
		local body = Instance.new("BodyVelocity")
		body.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
		body.Velocity = Character.HumanoidRootPart.CFrame.LookVector * 30
		body.Parent = Character.HumanoidRootPart
		Character.Humanoid.WalkSpeed = 4
		hptrack:Play()
		Hitbox:HitStart() 
		Hitbox.OnHit:Connect(function(hit, humanoid)
			if humanoid.Parent.Name ~= script.Parent.Parent.Name then
				--7919154517
				local vel = Instance.new("BodyVelocity")
				vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
				vel.Velocity = Character.HumanoidRootPart.CFrame.LookVector * 30
				vel.Name = "vel"
				vel.Parent = hit
				script.Parent.spp:Play()
				
				humanoid:TakeDamage(15)
				local stuntime = humanoid.Parent.StunTime.Value
				local brektrack = humanoid:LoadAnimation(brek)
				if humanoid.Parent.IsBlocking.Value == true then
					brektrack:Play()
					humanoid.Parent.HumanoidRootPart.Anchored = true
					humanoid.Parent.Fists.Enabled = false
					wait(5)
					humanoid.Parent.HumanoidRootPart.Anchored = false
					humanoid.Parent.Fists.Enabled = true
				end
				humanoid.Parent.stun.Value = true
				humanoid.Parent.IsBlocking.Value = false
				humanoid.Parent.HumanoidRootPart.Orientation = Character.HumanoidRootPart.Orientation + Vector3.new(0,180,0)
				wait(0.5)
				stuntime = 0.5
				vel:Destroy()
			end
		end)
		wait(0.3)
		body:Destroy()
		wait(0.2)
		Hitbox:HitStop() 
		wait(1)
		humanoid.Parent.stun.Value = false
		db = false
		if IsBlocking.Value == false then
			Character.Humanoid.WalkSpeed = 16 
		end
		wait(5)
		spdb = false
	end
end)

If anyone minds looking trough this code and telling me how to improve it that would be great, my stun system is completely dumb and idk how to do it else, i just need feedback. Combat game | UPDATE 0 - Roblox
If you wanna try it out, go to this game.

1 Like

500 lines?! You really worked hard for this :slight_smile: .

1 Like

i wanted to make it good but there are so many flaws, like the stun sometimes breaks and stuff. I really need to get it figured out

1 Like

Really cool system, one problem I found, pressing the R key flings me across the map

1 Like

Honestly, the script looks like complete chaos, it’ll be really hard to debug or read later.

1 Like

i gave up on it i realised it was dumb lol