Anti-Gravity room effect not working properly

I am trying to make an Anti-Gravity room similar to that in Innovation Labs by @madattak. I tried using Vector Forces which has gotten the player to be tossed around the room like they should be, but the effect is really extreme with the player being flung out of the map after just 30 seconds in the room.

Here is my code:

script.Parent.Touched:Connect(function(part)
	local char = part.Parent
	if char.ClassName == "Accessory" then
		char = part.Parent.Parent
	end
	if char:WaitForChild("HumanoidRootPart") then
		
		local attachment = Instance.new("Attachment")
		attachment.Name = "VectorAttachment"
		attachment.Axis = Vector3.new(1,0,0)
		attachment.SecondaryAxis = Vector3.new(0,1,0)
		attachment.WorldAxis = Vector3.new(1,0,0)
		attachment.WorldSecondaryAxis = Vector3.new(0,1,0)
		attachment.Parent = char.HumanoidRootPart
		
		local vectorForce = Instance.new("VectorForce")
		vectorForce.Archivable = true
		vectorForce.Enabled = true
		vectorForce.ApplyAtCenterOfMass = true
		vectorForce.Force = Vector3.new(0, workspace.Gravity / char.HumanoidRootPart:GetMass() , 0)
		vectorForce.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
		vectorForce.Parent = char
		vectorForce.Attachment0 = attachment
		
		char.Humanoid.Sit = true
		
	end
end)

Is there any way to make the effect more like the gravity room in Innovation Labs, or at least less extreme?

Does anyone know how to fix this?

Have you tried changing the gravity directly? If I’m not wrong you are able to change the gravity locally

1 Like

Changing the workspace gravity doesn’t work from what I’ve tried.

You’re adding forces every time a character touches an anti-gravity brick, and those forces add up to create one massive force.
Edit for clarification: .Touched will fire multiple times as a character walks over the part, which leads to the script adding an indefinite number of forces to said character. It might add one force, it might add a hundred. .Touched on its own is not a reliable way to do something once.

Instead, you should be using a “zone” part to represent your anti-gravity room. Apply the anti-gravity force only when a character has entered the zone, and remove the force once they leave the zone. You can use ZonePlus to detect when a character has entered or left the anti-gravity room, or use your own zone implementation.

1 Like