Where do I place the check. I inconsistently use both interchangeably (they refer to the same object).
The callback throw error when Humanoid.RootPart is destroyed. I could use multiple if statements, but I don’t like it. I want to end the callback.
It just wait until a certain velocity range, the HumanoidRootPart could be destroyed during waiting, throwing an error. I just wonder if could stop it from a seperate thread rather than using if statements. I had another idea: and exist
What about this? I did a lil rewrite of your code. 50/50 chance it has errors
bodyPosition.Destroying:Once(function()
humanoid.RootPart.AssemblyLinearVelocity = Vector3.new(0, 50, 0)
while humanoid and humanoid.RootPart and task.wait() do
local X = humanoid.RootPart.AssemblyLinearVelocity.Y < 0
if not X then continue end
local Y = math.abs(humanoid.RootPart.AssemblyLinearVelocity.Y) < 0.1
if not Y then continue end
break
end
if not humanoid or not humanoid.RootPart then return end
local fallDamage = (humanoid.MaxHealth - humanoid.Health) / 4
applyDamageToHumanoid(humanoid, fallDamage)
local damagePart = Utility.createInstance("Part", {
Size = Vector3.new(10, 1, 10),
CFrame = CFrame.new(humanoid.RootPart.Position - Vector3.new(0, 2, 0)),
Anchored = true,
CanCollide = false,
Material = Enum.Material.Neon,
Color = Color3.fromRGB(255, 150, 0),
Transparency = 0.7
})
damagePart.Parent = workspace
local tween = TweenService:Create(damagePart, TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {Transparency = 1, Size = Vector3.new(15, 0.5, 15)})
tween:Play()
Utility.addToDebris(damagePart, 0.5)
end)
local s = true
while humanoid.RootPart and task.wait() do
if s then
if humanoid.RootPart.AssemblyLinearVelocity.Y < 0 then
s = false
humanoid.RootPart.AssemblyLinearVelocity -= Vector3.new(0, 500, 0)
end
elseif humanoid.RootPart.AssemblyLinearVelocity.Y < 0 then
break
end
end
local s = true
while humanoid.RootPart and task.wait() do
local RootVel = humanoid.RootPart.AssemblyLinearVelocity
if s then
if RootVel.Y < 0 then
humanoid.RootPart.AssemblyLinearVelocity -= Vector3.new(0, 500, 0)
s = false
end
else
if RootVel.Y < 0 then break end
end
end