Hey, I am currently working on an air combo system. It works great on Dummy’s but it’s lagging a lot on players
task.spawn(function()
if string.len(Seq) == 3 and canAir == true then
local weld = Instance.new("Motor6D")
weld.Part0 = ehumanoidRP
weld.Part1 = Humrp
weld.C0 = weld.Part0.CFrame:ToObjectSpace(weld.Part1.CFrame)
weld.MaxVelocity = 0.1
weld.Parent = weld.Part0
weld.Name = "canAir"
local vel = Instance.new("BodyPosition",Humrp)
vel.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
vel.Position = ehumanoidRP.Position + Vector3.new(0,30,0)
vel.Name = "vel"
game.Debris:AddItem(vel,.4)
wait(.4)
Humrp.Anchored = true
land = true
delay(1,function()
land = nil
weld:Destroy()
Humrp.Anchored = false
end)
elseif string.len(Seq) == 4 and canAir == true then
if Humrp:FindFirstChild("vel") then
repeat wait()
until not ehumanoidRP:FindFirstChild("canAir")
end
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,-65,0)
game.Debris:AddItem(Evel,.3)
local Egyro = Instance.new("BodyGyro",ehumanoidRP)
Egyro.D = 150
game.Debris:AddItem(Egyro,.5)
land = true
if ehumanoid.FloorMaterial ~= nil and land == true then
land = nil
wait(.3)
game.ReplicatedStorage.Camera.Explosion:FireClient(Player)
game.ReplicatedStorage.RocksVFX:FireClient(Player,ehumanoidRP,6,20,1.5,3)
wait(.1)
Rocks(ehumanoidRP)
Rocks(ehumanoidRP)
Rocks(ehumanoidRP)
end
end
end)
task.spawn(function()
if canAir == false and string.len(Seq) == 4 then
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,1,0)
game.Debris:AddItem(Evel,.3)
local Egyro = Instance.new("BodyGyro",ehumanoidRP)
Egyro.D = 150
game.Debris:AddItem(Egyro,.5)
local decimal = 0
game.ReplicatedStorage.Camera.Explosion:FireClient(Player)
end
end)
This is my code if you know how to fix this or any suggestions how to optimize it let me now