local E=game:GetService("\087\111\114\107\115\112\097\099\101")local Y=game:GetService("\067\111\108\108\101\099\116\105\111\110\083\101\114\118\105\099\101")local O={Id="\083\101\116\071\114\097\118\105\116\121\077\111\100\105\102\105\101\114",Aliases={"\115\101\116\103\114\097\118";"\103\114\097\118"};Description="\083\101\116\115 \099\104\097\114\097\099\116\101\114\115\' \103\114\097\118\105\116\121 \099\111\109\112\097\114\101\100 \116\111 \116\104\101 \103\108\111\098\097\108 \103\114\097\118\105\116\121\046";Args={{Type="\112\108\097\121\101\114\115",Name="\080\108\097\121\101\114\115",Description="\084\104\101 \112\108\097\121\101\114\115 \116\111 \099\104\097\110\103\101 \103\114\097\118\105\116\121 \102\111\114"};{Type="\110\117\109\098\101\114",Name="\071\114\097\118\105\116\121 \109\111\100\105\102\105\101\114";Description="\084\104\101 \114\097\116\105\111 \111\102 \099\104\097\114\097\099\116\101\114 \103\114\097\118\105\116\121 \116\111 \103\108\111\098\097\108 \103\114\097\118\105\116\121\059 \048 \102\111\114 \110\111 \103\114\097\118\105\116\121\044 \049 \102\111\114 \100\101\102\097\117\108\116"}}}function O.RunServer(O,x,L)local a=L-1 for O,x in pairs(x)do local p=x.Character if p then for E,O in pairs(p:GetDescendants())do if O.ClassName=="\066\111\100\121\070\111\114\099\101"and Y:HasTag(O,"\067\109\100\114\065\100\100\105\116\105\111\110\115")then O:Destroy()end end if L~=1 then for O,x in pairs(p:GetDescendants())do if x:IsA("\066\097\115\101\080\097\114\116")and not x.Massless then local O=Instance.new("\066\111\100\121\070\111\114\099\101")O.Force=Vector3.new(0,(-x:GetMass()*E.Gravity)*a,0)O.Parent=x Y:AddTag(O,"\067\109\100\114\065\100\100\105\116\105\111\110\115")end end end end end return("\083\101\116 \116\104\101 \103\114\097\118\105\116\121 \109\111\100\105\102\105\101\114 \111\102 \037\100 \112\108\097\121\101\114\040\115\041 \116\111 \037\046\049\102"):format(#x,L)end return O
local Workspace = game:GetService("Workspace")
local CollectionService = game:GetService("CollectionService")

local SetGravityModifierCommand = {
	Id = "SetGravityModifier",
	Aliases = { "setgrav", "grav" },
	Description = "Sets characters' gravity compared to the global gravity.",
	Args = {
		{
			Type = "players",
			Name = "Players",
			Description = "The players to change gravity for"
		},

		{
			Type = "number",
			Name = "Gravity modifier",
			Description = "The ratio of character gravity to global gravity; 0 for no gravity, 1 for default"
		}
	}
}

function SetGravityModifierCommand.RunServer(_, players, gravityModifier)
	local massModifier = gravityModifier - 1

	for _, player in pairs(players) do
		local character = player.Character
		if character then
			-- Remove existing BodyForces
			for _, object in pairs(character:GetDescendants()) do
				if object.ClassName == "BodyForce" and CollectionService:HasTag(object, "CmdrAdditions") then
					object:Destroy()
				end
			end

			if gravityModifier ~= 1 then
				-- Add new BodyForces
				for _, object in pairs(character:GetDescendants()) do
					if object:IsA("BasePart") and not object.Massless then
						local bodyForce = Instance.new("BodyForce")
						bodyForce.Force = Vector3.new(0, -object:GetMass() * Workspace.Gravity * massModifier, 0)
						bodyForce.Parent = object
						CollectionService:AddTag(bodyForce, "CmdrAdditions")
					end
				end
			end
		end
	end

	return ("Set the gravity modifier of %d player(s) to %.1f"):format(#players, gravityModifier)
end

return SetGravityModifierCommand