One area zero gravity

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? instead of the whole game being in zero gravity i want only a room to be in zero gravity so that when you enter you have zero gravity and when you leave you have normal gravity

  2. What is the issue? i dont know how to continue

  3. What solutions have you tried so far? been searching on google and other sites but did not find anything

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!


antigrav = 1
gravforce = 195.5729088953 * antigrav


function check(object)
	for i = 1, #object do
	wait()
	add(object[i])
	end
end

function add(object)
	if object.className == ("Model") or object.className == ("Tool") or object.className == ("Accoutrement") then
	check(object:getChildren())
	end
	if object.className == ("Part") or object.className == ("Truss") then
		if object.Anchored == false then
		local bforce = Instance.new("BodyForce")
		bforce.force = Vector3.new(0, ((object:getMass())*gravforce), 0)
		bforce.Parent = object
		end
	end
end
check(workspace)

game.Workspace.ChildAdded:connect(function(object) add(object) end)

1 Like

I’d create an invisible part in this area, anchor it plus make it cancollide so the players would think there is actually nothing but in reality it is. Then I’d use Touched so we will know when player enters area and once they leave the part I’d use TouchEnded so we will know when the player leaves the area. For the end, all you have to do is change the gravity of the local player in help with functions I just mentioned.

5 Likes

You could use a touched event, or check to see if the user is in a Region3, which may make it easier as you won’t have the part in the way, and it can be a bit more powerful than a simple touched event. https://developer.roblox.com/en-us/api-reference/datatype/Region3/index.html

You can then do workspace:FindPartsInRegion3(region) and iterate through.

Cheers!

1 Like

Touched isnt a really good option for that, I suggest using region 3 https://developer.roblox.com/en-us/api-reference/datatype/Region3/index.html