Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How do you change a bricks gravity so it almost floats?

Asked by 10 years ago
local gravity = game.Workspace.Part.SpecificGravity

gravity = .9999999999999

end

This is not working for me and I don't know why. Can someone help?

0
You cannot edit the SpecificGravity property, and what is the purpose of your 'end' in line 5? RedCombee 585 — 10y
0
I don't know but I that is what you do. I am new at scripting and I want to make it almost float so that would b really helpfull if someone knew how. noob1126 34 — 10y
0
Use a BodyForce, BodyPosition, or BodyVelocity object. Perci1 4988 — 10y
0
Well, in this code, you're not even attempting to set the Part's SpecificGravity, even though it's a locked property. What you're actually doing is setting the gravity variable to .999.. The best way to make a part float, is to just Anchor it. Tkdriverx 514 — 10y
1
Look up "hover bricks" in free models, and analyze how they work. I'm willing to bet that (the working ones) will be very similar to what you're trying to code; examining already created code is one of the most beneficial things to do for beginners. RoboFrog 400 — 10y

1 answer

Log in to vote
2
Answered by 10 years ago

First off, you need a BodyForce. Put that into the brick, and then edit the force so that X and Z are both 0, but Y is the number you need to counteract the gravity of the brick.

ROBLOX's gravity is about 196.2 studs/second^2. Just like Earth's gravity is 9.81 meters/second^2

The gravity of a brick is measured by its volume. So to find the volume of the Brick, simply multiply its Length by its Width by its Height: Part.Size.X * Part.Size.Y * Part.Size.Z

Finally, you have to counter the gravity of the brick, so you have to multiply the volume of the brick by ROBLOX's gravitational acceleration, and you get this: Part.Size.X * Part.Size.Y * Part.Size.Z * 196.2.

Once you have all that done, just put edit the BodyForce's force, like so:

local BodyForce = script.Parent.BodyForce
local Part = script.Parent
BodyForce.force = Vector3.new(0,Part.Size.X * Part.Size.Y * Part.Size.Z * 196.2,0)

Hope this helped!

Ad

Answer this question