Need help with an obby air vent

I want to create a vent-type thing that shoots air up, boosting the player into the air. With my code, the player glitches a bunch in the air, and doesn’t stay up. My code is:

local Vent = script.Parent

local function PlayerTouched(Part)

local Parent = Part.Parent

	if ( game.Players:GetPlayerFromCharacter(Parent)) then

		local HRP = Parent:FindFirstChild("HumanoidRootPart")
		local BodyVelocity = Instance.new("BodyVelocity", HRP)
		BodyVelocity.Velocity = Vector3.new(0,30,0) -- Sets velocity
		wait(.75)
	BodyVelocity:Destroy() -- Deletes the force, making the player start to come back down.
	
	end

end

Vent.Touched:connect(PlayerTouched)

Any suggestions for how to make it work consistently? Thanks in advance.

Are you still using the 2nd argument of Instance.new()? That got deprecated a while ago.

Remember to use task.wait()

Use debris to handle parts that you wanna destroy later.

Debris:AddItem(BodyVelocity, 0.75)

An alternative to the deprecated Body Movers are the new constraints.

I hope this solves anything.

BodyVelocity.Velocity = HRP.CFrame.UpVector * 70

Also, try adjusting the wait()

Maybe it’s because it’s getting deleted before the player can fully make it up?

Your character continues to move up as long as the BodyVelocity is there. If you extend the time, your character would just keep going up for as long as the wait() time is.

Maybe I don’t fully understand the problem are you trying to make a airvent that launches the player or keeps the player in the air
If its the first one then I would do something like this

local mass = 0
for _,v in pairs(character:GetDescendants()) -- children works but I do this to make sure
   if v:IsA("BasePart") then
      mass += v.Mass -- or v:GetMass() if you feel like it
   end
end 
bodyvelocity.Velocity = direction * mass

what do you mean by glitching in the air btw

I am trying to make one that keeps the player in air, and by glitching I mean that the player doesn’t go up and down to the same points, but will sometimes go down so far that they hit the vent and it will stop working.

Forking off @Bubblebuddy200 code. Here is something that should work.

local Parent = script.Parent
local travelspeed = 10 --Higher = faster = need to lower duration
local duration = 2 --2 seconds

local Cooldown = {}

Parent.Touched:Connect(function(p)
	local mass = 0
	local player = game.Players:GetPlayerFromCharacter(p.Parent)
	if player then
		if not Cooldown[player.Name] then Cooldown[player.Name] = os.time() end
		if Cooldown[player.Name] <= os.time() then
			Cooldown[player.Name] = os.time() + 2
			for _,v in pairs(player.Character:GetDescendants()) do
				if v:IsA("BasePart") then
					mass += v:GetMass()
				end
			end 
			local HRP = player.Character:FindFirstChild("HumanoidRootPart")
			local BodyVelocity = Instance.new("BodyVelocity", HRP)
			BodyVelocity.Velocity = Vector3.new(0,travelspeed,0) * mass
			game:GetService("Debris"):AddItem(BodyVelocity, duration)
		end
	end
end)

Server script inside of a part.