Making NPCs float

I’m currently trying to accomplish making a bee float a few studs off the ground, while attacking nearby humanoids

The problem is, I don’t know how I would make the bees float(body-velocities made the bees keep on floating up)

Really the only things I’ve tried were body-movers, but another problem is that I don’t understand the concept that much, I’ve looked at a lot of topics on the forum, and nothing really helped.

Some details, the bees are small, they have animations, and they attack nearby players.

any help would be appreciated, thanks

You need to set there position on the y on instance then give them a body force of the bees mass times the gravity

1 Like

How would I get the bee’s gravity?

use a generic loop to get the bees mass then multiply it by gravity

I don’t think I understand, isn’t force a vector3 value? so wouldn’t the bee’s mass x the gravity return a number?

Yes and the vector is y so 0,force,0

So something like this?

local gravitymassratio = script.Parent:GetMass() * workspace.Gravity
BForce.Force = ,gravitymassratio, 0)

Yes that would work. The bee would have to be can collide off or else, if a character touches it would do some weird things.

I would need the mass of the entire model though right?

Yes if it’s a model then just loop through the model, check if the value if a base part of a mesh part then add it to the mass.

So it would be like this:

local model = PUTMODELHERE
local mass_sum = 0
local force = PUTFORCEHERE

for i, v in pairs(model:GetChildren()) do
   if v:IsA("BasePart") or v:IsA("MeshPart") then
      mass_sum = mass_sum + v:GetMass()

force.Force =, mass_sum * workspace.Gravity, 0)

I made a script like that but, after I tested, the bee spawned on the floor, I went to the server side and moved the bee up and the floating worked, I tried setting the bee’s position and I’m not sure why, but the bee still stays on the floor until you move it on the server side, here is what the script looks like

function getmodelmass(model)
	local totalmass = 0
	for i, v in pairs(model:GetChildren()) do
		if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("UnionOperation")then
			totalmass = totalmass + v:GetMass()
	return totalmass
local totalmass = getmodelmass(script.Parent.Parent)
local massgravityratio = totalmass * workspace.Gravity

Bforce.Force =, massgravityratio, 0)
script.Parent.CFrame = workspace.Startpos.CFrame

You have to place the bee in the air before the game starts.

The bee is already in the air, but weirdly enough, It still starts on the ground :thinking:

Another problem is, even though its off CanCollide, when it gets touched, it flies away into the abyss