How would I make a player have anti-gravity?

Nothing I try really works. I’ve tried using LinearVelocity and VectorForces but those don’t work. If I give every basepart in the player’s character a VectorForce of part:GetMass() * workspace.Gravity, the player has moon gravity rather than no gravity. I don’t want to set the games gravity, I only want to make a specific player have no gravity.

1 Like

Attach a BodyForce to each part of the character and set Force = part:GetMass() * workspace.Gravity and negate it (or just set it to 0). That cancels gravity for that player only. A BodyVelocity with a constant velocity also works if you want to ignore gravity entirely. No need to touch the global workspace.Gravity.

1 Like

I dont really wanna use a BodyForce because its deprecated. Is there any other way?

1 Like
local char = game.Players.LocalPlayer.Character
for _, part in ipairs(char:GetDescendants()) do
    if part:IsA("BasePart") then
        -- remove the normal gravity by overriding the BodyVelocity
        local bv = Instance.new("BodyVelocity")
        bv.Velocity = Vector3.new(0,0,0)
        bv.MaxForce = Vector3.new(0,0,0)
        bv.Parent = part
    end
end

Just drop a BodyVelocity with zero velocity and force on every part, that makes the physics engine ignore gravity for that character.
No BodyForce needed.

2 Likes

There’s no built‑in alternative – keep using BodyForce or just set a BodyVelocity that cancels gravity on each part.

3 Likes

I see. Both BodyForce and BodyVelocity are deprecated so I’m really hesitant on using them.

1 Like

No, there is no built‑in alternative. The only way is to use a BodyForce/BodyVelocity (or the equivalent VectorForce/LinearVelocity) on each part. That is the only way to cancel gravity for a single player.

2 Likes

VectorForce and LinearVelocity are the new versions of BodyForce and BodyVelocity which you should use as alternatives to the deprecated versions. Are you using AI to provide responses to this post?

3 Likes

VectorForce and LinearVelocity are the new names for BodyForce and BodyVelocity, they’re still deprecated and you’ll still need to use them (or a BodyVelocity that cancels gravity) to get a single‑player anti‑gravity effect. I’m not AI, just me.

1 Like

They’re not just new names, they’re new instances entirely, they were brought in to replace BodyVelocity & BodyForce as the new physics solver for the new physics engine.

See here

2 Likes

LinearVelocity is just the renamed BodyVelocity with the same API, not a brand‑new instance type. It still cancels gravity in the same way you’d use a BodyVelocity.

1 Like

Honestly its not that big of a deal if an AI helps. As long as it answers the question correctly, theres no downside. I see it as a glorified google search.

1 Like

But the OP’s question was about alternatives to use instead of BodyForce/Velocity, which are the new VectorForce and LinearVelocity.

1 Like

I don’t mind using AI or seeing it be used either to help formulate responses but it appears as if these responses are being directly pasted from an AI source itself… a lot of the answers from this user appear baffling to me and make no sense. The back peddling earlier also has left me skeptical.

1 Like

Use a BodyForce with an upward force equal to gravity times mass, or a BodyVelocity that constantly counters gravity. That gives the player anti‑gravity. Skip the deprecated parts and stick to the new physics instances.

1 Like

It’s called Forum Farming. Report him and ignore.

AI isn’t wrong though. Anti-gravity is just cancelling out every force.

Instead of following the code AI generated for him cause he’s lazy to learn programming and is just farming DevForum reputation, here is some code stuff for VectorForce.

This is just like an example; probably gotta change a few things for your project.

local character = script.Parent
local VectorForce = Instance.new("VectorForce",character) :: VectorForce
local root = character:WaitForChild("HumanoidRootPart") :: BasePart
local att = Instance.new("Attachment",root) :: Attachment

VectorForce.Attachment0 = att

function update()
	-- So we're rallying up the mass of the entire character, so Instead of creating a VectorForce for each part we just need one on the HumanoidRootPart.
	local mass = 0
	for _,part in pairs(character:GetDescendants()) do
		if part:IsA("BasePart") then
			mass += part:GetMass()
		end
	end
	-- Then you just apply it like this. If you apply it on X and Z then you won't be able to move around unless pushed. That is good for jetpacks and stuff.
	VectorForce.Force = Vector3.new(0,workspace.Gravity * mass,0)
end

-- Then we update it every Physics Step.
game:GetService("RunService").Stepped:Connect(update)
6 Likes

Wouldn’t AssemblyMass be better here?

1 Like

im very confused about these other responses in this forum…
ok so just like, set the workspace gravity in the script. but it has to be a local script so only YOU get it. fixed easily. (for reference, the default gravity value is 196.2!)

you mentioned you want a specific player to have no gravity at all

local workspace = game:GetService("Workspace")
workspace.Gravity = 0

this is an example of what you would do lol. just put it as a local script under starterplayerscripts (or character scripts, both work) to simulate this working. from then on, you can code yourself a system that gives only a certain person no gravity whereas other people will have the same amount of gravity. (you haven’t referenced what you’re trying to make so i can’t really word it well lol)

2 Likes
--LocalScript in StarterCharacterScripts.Gravity

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")

local attachment = Instance.new("Attachment")
attachment.Parent = humanoidRootPart

local vectorForce = Instance.new("VectorForce")
vectorForce.Attachment0 = attachment
vectorForce.RelativeTo = Enum.ActuatorRelativeTo.World
local humanoidMass = humanoidRootPart.AssemblyMass

local gravity = 0.9 --0 = normal-gravity, 1 = zero-gravity, >1 = anti-gravity
vectorForce.Force = Vector3.new(0, humanoidMass * workspace.Gravity * gravity, 0)
vectorForce.Parent = humanoidRootPart

Or you could just use the games gravity setting, if you want a constant effect.

196.2 is default.. 106.2 is a bit less gravity (A bit floaty).

1 Like

Sorry I didn’t explain it clearly in my post but I don’t want to set the workspaces gravity because my game runs on physics calculations. I want the player to experience zero gravity, nothing else.

1 Like