Low Gravity Room with a Local Boundary thumbnail
0 views0 copies0 likes

Low Gravity Room with a Local Boundary

Universal script

Copy it, then test it in your own Studio place.

Combat & movement Verified

Script code

29 lines · 1.2 KB
Download
local Players = game:GetService("Players")local room = workspace:WaitForChild("GravityRoom")local active = {}local function clear(player)	local entry = active[player]	if entry then entry.force:Destroy(); entry.attach:Destroy(); active[player] = nil endendPlayers.PlayerRemoving:Connect(clear)while room.Parent do	local half = room.Size / 2	for _, player in Players:GetPlayers() do		local root = player.Character and player.Character:FindFirstChild("HumanoidRootPart")		local p = root and room.CFrame:PointToObjectSpace(root.Position)		local inside = p and math.abs(p.X) <= half.X and math.abs(p.Y) <= half.Y and math.abs(p.Z) <= half.Z-- …open Get script for the full source

About this script

Create a transparent anchored box called GravityRoom and set CanCollide off. Players inside get an upward VectorForce equal to 65 percent of their weight. The force is destroyed as soon as the current root leaves the room, so the rest of the map keeps its usual gravity. Test entering from more than one direction and resetting inside the volume.

Comments

Share what works, ask questions, or report an issue.

0

Log in to leave a comment.

No comments yet

Be the first to share your thoughts!

Raw Luau source

local Players = game:GetService("Players")
local room = workspace:WaitForChild("GravityRoom")
local active = {}
local function clear(player)
	local entry = active[player]
	if entry then entry.force:Destroy(); entry.attach:Destroy(); active[player] = nil end
end
Players.PlayerRemoving:Connect(clear)
while room.Parent do
	local half = room.Size / 2
	for _, player in Players:GetPlayers() do
		local root = player.Character and player.Character:FindFirstChild("HumanoidRootPart")
		local p = root and room.CFrame:PointToObjectSpace(root.Position)
		local inside = p and math.abs(p.X) <= half.X and math.abs(p.Y) <= half.Y and math.abs(p.Z) <= half.Z
		if active[player] and (not inside or active[player].root ~= root) then clear(player) end
		if inside then
			if not active[player] then
				local attach = Instance.new("Attachment", root)
				local force = Instance.new("VectorForce", root)
				force.Attachment0, force.RelativeTo = attach, Enum.ActuatorRelativeTo.World
				force.ApplyAtCenterOfMass = true
				active[player] = {root = root, force = force, attach = attach}
			end
			active[player].force.Force = Vector3.new(0, root.AssemblyMass * workspace.Gravity * 0.65, 0)
		end
	end
	task.wait(0.1)
end
for player in pairs(active) do clear(player) end