Is there a better way have a negative gravity other then putting body forces in every unanchored part in the game? right now I cant set gravity to a negative number and so is there a better way then to go through all of the games descendents, check if there unanchored and add a body velocity
You could put a script in a part called “Game” and put this code in:
game:GetGui().GravityStrength = -100
​
Then make all your parts unanchored.
Whats your use case?
tryna make some gravity wave thing where gravity goes up and down following a sine wave periodically for some special round thing
Can’t you just manually set the workspace.Gravity property?
what.
I could but I cant set it negative. thats the issue. it wont let me.
What? If you didn’t understand that then you need to study lua before you write more code.
maybe i am slow. explain this more. the instruction you want me to do to get till here.
I’m really not trying to be rude, and I know there’s the whole “no question is an easy question and there is no such as a stupid question” But you are in over your head, you are trying to write code you can’t yet, that you don’t understand.
I will help you, but I really just recommend going through more lua lessons, and learning the fundamentals, like a simple Hello World.
dude. look. you want me to make this code:
local game = script.parent
game:GetGui().GravityStrength = -100
so baseparts dont even have the :GetGui() method. so please explain im genuinely curious what the apple sauce ur saying.
and
game -- just as itself!
doesnt have :GetGui() thing either
Oh, my apologies for the miscommunication. I thought you wanted to change gravity for all parts to negative.
To change the gravity for a particular part, you would have to access that part and change its gravity. Assuming the part is named “part,” you would use the following code to change its gravity:
part.Gravity = -100
This would set the gravity for the “part” to a negative value, which would cause it to fall upward.
gravity is not a member of baseparts btw. i dont even need to check. how long have u been scripting?
This is kind of a hard problem, because gravity does not push stuff up, only down. What if you flip the entire map upside down?
me reading xDeltaXen replies:

Why do you want a different way?
I think this way is the only way to do it though
also xDeltaXen is so weird with the replies
game:GetGui() doesnt exist and part.GravityStrength or any part.Gravity related properties dont exist
And he seems to get basic OOP wrong in this post Trying to get autocomplete for a function
And he seems to not know about typechecking in this post Animation not playing help - #6 by stinkyfart99999999
LET HIM COOK
NO THEY ALL EXist TRUST!
So True.
yay, I am proud of him
You could apply the BodyForce solely to the root part of models if you’re concerned about complex models having many BodyForces for each part, while treating lonely parts as their own model.
local rootParts = {}
local function newBodyForce(target : BasePart)
local bodyForce = Instance.new("BodyForce")
bodyForce.Force = Vector3.new(0, target.AssemblyMass * workspace.Gravity, 0)
bodyForce.Parent = target
end
local function onDescendantAdded(descendant : Instance)
if descendant:IsA("BasePart") then
local root = descendant.AssemblyRootPart
if root then
if table.find(rootParts, root) == nil then
table.insert(rootParts, root)
newBodyForce(root)
end
else
table.insert(rootParts, descendant)
newBodyForce(descendant)
end
end
end
workspace.DescendantAdded:Connect(onDescendantAdded)
for _, descendant : Instance in pairs(workspace:GetDescendants()) do
onDescendantAdded(descendant)
end
I’m not sure if having many weak BodyForces compared to few strong ones even has a performance impact so I’d recommend testing before deciding on a solution. Also keep in mind that if models “break” apart then you would have to recalculate the BodyForces for the original model and the new one formed by the parts that broke off.
Bros in middle school ![]()
![]()
![]()