I am currently doing an air combo system and everything works fine, but sometimes the character teleports to the enemy misaligned, like this
This happens randomly, sometimes its perfect, and sometimes it’s misaligned. The script is here:
My idea is that I would first make the enemy to look at the player using CFrame.lookAt(), after that I would set the model’s CFrame close to the player like how you did in your code. Also, Model:SetPrimaryPartCFrame() is deprecated, use Model:PivotTo() instead.
Somewhere I saw that use math.huge for max force in bodymovers was unstable (this may be fixed/changed now), so maybe try lowering it to a number that produce the same effect?
After a bit of testing, I think this script which is a kick grab on the air combo bugs out the alignment as this bug is for individual players. Here’s the script.
Grab:
for i,v in pairs(Victim:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("MeshPart") then
if not NPC then
v:SetNetworkOwner(Player)
end
v.CollisionGroupId = 1
v.Massless = true
end
end
local Weld = script.TorsoToHum:Clone(); Weld.Part0 = Char.Torso; Weld.Part1 = Victim.HumanoidRootPart
Weld.Parent = Victim.HumanoidRootPart
Victim:WaitForChild("Humanoid"):LoadAnimation(game.ServerStorage.ClassAnims.Fists.AirVictim):Play()
Ungrab:
if i.HumanoidRootPart:FindFirstChild("TorsoToHum") then
i.HumanoidRootPart.TorsoToHum:Destroy()
end
for i,e in pairs(i:GetDescendants()) do
if e:IsA("BasePart") or e:IsA("MeshPart") then
if not EnemyNPC then
e:SetNetworkOwner(EnemyPlayer)
end
e.CollisionGroupId = 0
e.Massless = false
end
end
Obviously this may not be the reason, but I threw this out here for the most possible information.
Tried this, but it doesn’t work unfortunately. The misalignment is a one time thing and stays everytime I use it on that individual character, so I am suspecting the grab may have done this.
AirComboCrit = function(Char)
local hit = {}
local ign = {}
Char:WaitForChild("Humanoid"):LoadAnimation(game.ServerStorage.ClassAnims.Fists.AirIdle):Play()
Char:SetAttribute("AirCombo", 0)
Char:SetAttribute("Freeze", 1)
Char:SetAttribute("Stun", 1)
task.wait()
Char:SetAttribute("AutoRotate", 1)
local Player, NPC = Weapons:PlayerNPCCheck(Char); if Player == nil then return end
local bv = Instance.new("BodyVelocity"); bv.Velocity = Char.HumanoidRootPart.CFrame.LookVector*50.5+Vector3.new(0,-10,0); bv.Parent = Char:WaitForChild("HumanoidRootPart");
for i = 1, 70 do
ClientFX:FireAllClients("ShadowPlayer", {
Character = Char,
Dura = .4
})
local Parts = Weapons:NewHitbox(Char["Left Leg"].CFrame * CFrame.new(0,-.5,-1), Vector3.new(2,4,3))
for _, Part in next, Parts do
local Victim = Weapons:CheckPartIsLimb(Part)
if Victim and hit[Victim] == nil and Victim ~= Char then
hit[Victim] = true
Victim:SetAttribute("Freeze", 1); Victim:SetAttribute("Stun", 1)
for i,v in pairs(Victim:GetDescendants()) do
if v:IsA("BasePart") or v:IsA("MeshPart") then
if not NPC then
v:SetNetworkOwner(Player)
end
v.CollisionGroupId = 1
v.Massless = true
end
end
local Weld = script.TorsoToHum:Clone(); Weld.Part0 = Char.Torso; Weld.Part1 = Victim.HumanoidRootPart
Weld.Parent = Victim.HumanoidRootPart
Victim:WaitForChild("Humanoid"):LoadAnimation(game.ServerStorage.ClassAnims.Fists.AirVictim):Play()
end
end
for i,v in pairs(hit) do
table.insert(ign, i)
end
local raycastparams = RaycastParams.new(); raycastparams.FilterType = Enum.RaycastFilterType.Blacklist; raycastparams.FilterDescendantsInstances = {Char,ign}
local ray = workspace:Raycast(Char.HumanoidRootPart.Position, Vector3.new(0,-5.5,0), raycastparams)
if ray then
print(ray)
RecursiveBypass:Fire("ServerFunctions", "StopAnimation", Char, "AirIdle")
for i,v in pairs(hit) do
print(i)
RecursiveBypass:Fire("ServerFunctions", "StopAnimation", i, "AirVictim")
i:SetAttribute("Freeze", 0); i:SetAttribute("Stun", 0)
if i.HumanoidRootPart:FindFirstChild("TorsoToHum") then
i.HumanoidRootPart.TorsoToHum:Destroy()
end
local EnemyPlayer, EnemyNPC = Weapons:PlayerNPCCheck(i);
for i,e in pairs(i:GetDescendants()) do
if e:IsA("BasePart") or e:IsA("MeshPart") then
if not EnemyNPC then
e:SetNetworkOwner(EnemyPlayer)
end
e.CollisionGroupId = 0
e.Massless = false
end
end
end
break end
task.wait()
end
I’ll be posting the entire script that handles the CFrame of the enemy, then
module.AirCombo = function(Character)
local NPC = false
local ToolName, Tool = ServerFunctions.GetCharacterWeapon(Character)
print(Tool)
if not Tool then return end
local Cancelled = false
local Weapon = ToolName
local Player = game.Players:GetPlayerFromCharacter(Character)
if not WeaponModule[Weapon].AirCombo then
Character:BreakJoints()
return end
if ServerFunctions.CheckCooldown(Character, "AirCombo") then return end
ServerFunctions.AddCooldown(Character, "AirCombo", WeaponModule[Weapon].AirCombo)
if Player.Backpack.StatusEffects:FindFirstChild("AirComboTarget") and Player.Backpack.StatusEffects.AirComboTarget.Value ~= nil then
local Enemy = Player.Backpack.StatusEffects.AirComboTarget.Value
Enemy.HumanoidRootPart.AssemblyLinearVelocity = Vector3.new(0,0,0)
local CharPos = Character.PrimaryPart.Position; local EnemyPos = Enemy.PrimaryPart.Position; local EnemyCFrame = Enemy.PrimaryPart.CFrame; local CharCFrame = Enemy.PrimaryPart.CFrame;
local setvector2 = Vector3.new(CharPos.X, EnemyPos.Y, CharPos.Z)
Enemy:SetPrimaryPartCFrame(EnemyCFrame, setvector2)
Enemy:SetPrimaryPartCFrame(CharCFrame:ToWorldSpace(CFrame.new(0,0,-4.5) * CFrame.Angles(0,math.rad(180),0)))
local BodyPosition = Instance.new("BodyPosition"); BodyPosition.MaxForce = Vector3.new(math.huge,math.huge,math.huge); BodyPosition.P = 25000
BodyPosition.Position = EnemyPos + Vector3.new(0,7.5,0); BodyPosition.Parent = Enemy.HumanoidRootPart
local BodyPosition2 = BodyPosition:Clone(); BodyPosition2.Position = BodyPosition.Position + Vector3.new(0,0,3.5); BodyPosition2.Parent = Character.HumanoidRootPart
Character:SetPrimaryPartCFrame(EnemyCFrame:ToWorldSpace(CFrame.new(0,0,-4.5) * CFrame.Angles(0,math.rad(180),0)))
ServerFunctions.TempAttribute(Character, "AirCombo", "+1", 1)
Character:SetAttribute("AutoRotate", 1)
Enemy:SetAttribute("AutoRotate", 1)
local setvector = Vector3.new(EnemyPos.X, CharPos.Y, EnemyPos.Z)
local setvector2 = Vector3.new(CharPos.X, EnemyPos.Y, CharPos.Z)
--Character:SetPrimaryPartCFrame(CharCFrame, setvector)
Enemy:SetPrimaryPartCFrame(EnemyCFrame, setvector2)
while Character:GetAttribute("AirCombo") >= 1 do
task.wait()
end
BodyPosition:Destroy();
BodyPosition2:Destroy();
Character:SetAttribute("AutoRotate", 0)
Enemy:SetAttribute("AutoRotate", 0)
end
end
Create a part, get the player’s LookVector, offset it however many studs you want, then set the part’s CFrame to the result of (LookVector * Offset), then CFrame the enemy model to it.