For some reason, my character is just floating mid-air, far away from the initial position.
Other players, and the player themself, don’t see the character floating, but for some reason, the server does.
Printing the position of the characters limbs (other than the root part) will also give a result of being far away from the initial position.
What’s my code do?
Well, I am using a hold and release input method for my abilities. The problem arises after releasing the key for one specific skill.
When the key is held down, it anchores the characters humanoidrootpart, and tweens it upward.
After the tween is completed, a bodyposition is then instanced to the humanoidrootpart, the rootpart is then unanchored, and an animation plays.
After the key is released, the bodyposition is destroyed, the rootpart is anchored once again, and the character is tweened downward towards the mouse position.
if ability == "Phoenix" then
if level < 100 then return end
character:SetAttribute("Cooldown", true)
character:SetAttribute("HoldingV", true)
local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
local torso = character:FindFirstChild("Torso")
local LeftArm = character:FindFirstChild("Left Arm")
local RightArm = character:FindFirstChild("Right Arm")
local Emitter = Effects:FindFirstChild("PhoenixWing")
local EmitterLeft = Emitter:Clone()
local EmitterRight = Emitter:Clone()
EmitterLeft.Enabled = true
EmitterRight.Enabled = true
local AttachmentLeft = Instance.new("Attachment")
local AttachmentRight = Instance.new("Attachment")
EmitterLeft.Parent = AttachmentLeft
EmitterRight.Parent = AttachmentRight
AttachmentLeft.Parent = LeftArm
AttachmentRight.Parent = RightArm
LeftArm.Transparency = 1
RightArm.Transparency = 1
animationPlayer:FireClient(player, "rbxassetid://6657248879", humanoid, animator, false, "Inf", true, .8, false)
wait(.8)
humanoidRootPart.Anchored = true
local tweeningInfo = TweenInfo.new(2, Enum.EasingStyle.Quart, Enum.EasingDirection.Out, 0, false, 0)
local properties = {CFrame = humanoidRootPart.CFrame * CFrame.new(0, 500, 0)}
local newTween = tweenService:Create(humanoidRootPart, tweeningInfo, properties)
newTween:Play()
aconnection = newTween.Completed:Connect(function()
if aconnection then
aconnection:Disconnect()
end
local leapPosition = Instance.new("BodyPosition")
leapPosition.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
leapPosition.Position = humanoidRootPart.Position
leapPosition.Parent = humanoidRootPart
animationPlayer:FireClient(player, "rbxassetid://6657279100", humanoid, animator, false, "Inf", false, .8, false)
humanoidRootPart.Anchored = false
character:SetAttribute("SkillV", true)
end)
local shockwaveTweenInfo = TweenInfo.new(1.25, Enum.EasingStyle.Quint, Enum.EasingDirection.Out, 0, false, 0)
local shockwaveProperties = {Transparency = 1, Size = Vector3.new(575, 2, 575)}
local function createShockwave(pos)
local shockwave = Assets:FindFirstChild("Shockwave")
if shockwave ~= nil then
local clonedShockwave = shockwave:Clone()
local primary = clonedShockwave.PrimaryPart
if primary ~= nil then
primary.Anchored = true
primary.CanCollide = false
primary.BrickColor = BrickColor.new("Institutional white")
primary.Size = Vector3.new(45, 6, 45)
primary.Position = pos + Vector3.new(0, 2, 0)
clonedShockwave.Parent = specialEffects
local effectTween = tweenService:Create(primary, shockwaveTweenInfo, shockwaveProperties)
effectTween:Play()
debrisService:AddItem(clonedShockwave, 1.25)
for _, v in pairs(workspace:GetDescendants()) do
if v:IsA("Model") and v ~= character then
local enemyHuman = v:FindFirstChildOfClass("Humanoid")
local enemyTorso = v:FindFirstChild("HumanoidRootPart")
if enemyHuman ~= nil and enemyTorso ~= nil then
local distanceCheck = (enemyTorso.Position - pos).Magnitude
if distanceCheck <= 287.5 then
damageTargets(character, v, enemyHuman, 5 + (level / 7.2), "Fruit", "Explosion")
end
end
end
end
end
end
end
local released
released = character:GetAttributeChangedSignal("HoldingV"):Connect(function()
released:Disconnect()
if character ~= nil then
local newMarker = Instance.new("BoolValue")
newMarker.Name = "PhoenixLeap/"
newMarker.Parent = character
if aconnection ~= nil then
aconnection:Disconnect()
end
for _, v in pairs(humanoidRootPart:GetChildren()) do
if v:IsA("BodyPosition") then
v:Destroy()
end
end
if character ~= nil and humanoidRootPart ~= nil then
animationPlayer:FireClient(player, "rbxassetid://6657294721", humanoid, animator, false, 1, true, 0.4, false)
humanoidRootPart.Anchored = true
local mousePos = character:GetAttribute("MousePosition")
local endPos = mousePos + Vector3.new(0, 5, 0)
local newerInfo = TweenInfo.new(.45, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out, 0, false, 0)
local newerproperties = {Position = endPos, CFrame = CFrame.new(humanoidRootPart.Position, endPos)}
local newerTween = tweenService:Create(humanoidRootPart, newerInfo, newerproperties)
newerTween:Play()
local newconnection
newconnection = newerTween.Completed:Connect(function()
if newconnection then
newconnection:Disconnect()
end
humanoidRootPart.Anchored = false
for looping = 1, 6 do
createShockwave(mousePos)
wait(.15)
end
end)
end
debrisService:AddItem(newMarker, 1)
if EmitterLeft ~= nil and EmitterRight ~= nil then
AttachmentLeft:Destroy()
AttachmentRight:Destroy()
end
if LeftArm ~= nil and RightArm ~= nil then
LeftArm.Transparency = 0
RightArm.Transparency = 0
end
end
resetCooldown(character, 1.5)
resetKey(character, 8, "SkillV")
end)
end