Air Combat System

Hey, I have been working on a combat system that has air combat sadly my air combat still has a few bugs and isn’t fully optimised this is my code →

task.spawn(function()
							if string.len(Seq) == 3 and canAir == true then
								

	
								
								local weld = Instance.new("ManualWeld")
								weld.Part0 = ehumanoidRP
								weld.Part1 = Humrp
								weld.C0 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
								weld.Parent = weld.Part0
								weld.Name = "canAir"

								
								local vel = Instance.new("BodyVelocity",Humrp)
								vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
								vel.Velocity = Humrp.CFrame.upVector * 40
								game.Debris:AddItem(vel,.2)
								
								wait(.2)
								
								Humrp.Anchored = true
								
								delay(1,function()
									weld:Destroy()
									Humrp.Anchored = false
									
								end)
								
							elseif string.len(Seq) == 4 and canAir == true then
								ehumanoidRP:WaitForChild("canAir"):Destroy()
								Humrp.Anchored = false
								

								local Evel = Instance.new("BodyVelocity",ehumanoidRP)
								Evel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
								Evel.Velocity = Humrp.CFrame.lookVector * 50 + Vector3.new(0,-20,0)
								game.Debris:AddItem(Evel,.2)
								
								ehumanoid.StateChanged:Connect(function(old,new)
									if (old == Enum.HumanoidStateType.Freefall) or (new == Enum.HumanoidStateType.Landed)then
										game.ReplicatedStorage.Camera.Explosion:FireClient(Player)
										coroutine.wrap(function()
											for _, plr in pairs(game.Players:GetChildren())do
												game.ReplicatedStorage.RocksVFX:FireClient(plr,ehumanoidRP,3.5,20,1)
												
											end
										end)()
									end
								end)
							end						
						end)

It works “fine” but it has some bugs they are

  • If enemy dies you die to
  • Sometimes doesn’t show to some players
  • The Ground Throw is very bugy
  • It fires the event everytime the enemy jumps

Welding a player to a player basically connects the player to that player so when they die, the player also dies along with it. So I’d recommend using Motor6D so it can be animated as well as welded safely.

Using wait can be a bit buggy with what you’re doing due to the roblox physics engine.

I can’t see all of your code so I can’t determine why it fires everytime the enemy jumps but this is feedback to your code.

3 Likes
						ehumanoid.StateChanged:Connect(function(old,new)
									if (old == Enum.HumanoidStateType.Freefall) or (new == Enum.HumanoidStateType.Landed)then
										game.ReplicatedStorage.Camera.Explosion:FireClient(Player)
										coroutine.wrap(function()
											for _, plr in pairs(game.Players:GetChildren())do
												game.ReplicatedStorage.RocksVFX:FireClient(plr,ehumanoidRP,3.5,20,1)
												
											end
										end)()
									end
								end)

this part is the problem

Weld might not be great! Just a opinion! Since it can be buggy, and is probably the source of your opponent dying, causing you to die! Just separate body positions may be better!

Use a weldconstraint over a manualweld. The reason is because the older welds can tend to kill npcs / players that are welded to things. The joints can get a bit whacky during combat.