--[[for some reason, ROBLOX has decided that it is imperative that scripts DO NOT KNOW what physics
solver the place is using (same with part destroy height, but that is less annoying). Fortunately,
there's a simple hack that will tell us: surface motors. In PGS, surface motors are "braked" which
means that they always try to go to a certain speed, even when stopped. In Spring Physics, surface
motors "coast" which means that when they are stopped they are free to turn when stopped. We can use
this to determine the PGSness of the server. Three parts are created: an anchored part, an unanchored
part with a motor, and a brick on one side of the motor so it turns. If the motor turns, the server
is running spring physics.]]



local Value = game.ServerScriptService:FindFirstChild("PGSPhysicsSolverEnabled")
local Temporary = game.ServerScriptService:FindFirstChild("PGSPhysicsSolverEnabled TEMP")

if Value and not Temporary then--we want to be as lazy as possible. If another script already figured
	return Value.Value--out if the server is PGS or not, then lets just use their discovery
elseif Temporary then
	repeat--because it takes a second for the script to run, we want to make sure that we don't flood
	local inserted = game.ServerScriptService.ChildAdded:wait()--the thing with extra values.
	if inserted.Name == "PGSPhysicsSolverEnabled" then--but, we want to get back with the answer ASAP
		return inserted.Value
	end
	until false
else--well, it looks like this one will have to do the heavy lifting and run the test.
	local PGSTemp = Instance.new("BoolValue")--prevent a flood of values
	PGSTemp.Name = "PGSPhysicsSolverEnabled TEMP"
	PGSTemp.Parent = game.ServerScriptService
	local p1 = Instance.new("Part",workspace)
	p2 = Instance.new("Part",workspace)
	p3 = Instance.new("Part", workspace)
	p1.Anchored = true
	p1.CanCollide = false--having each property changed next to the others looks pretty
	p2.CanCollide = false
	p3.CanCollide = false
	p1.FormFactor = "Symmetric"
	p2.FormFactor = "Symmetric"
	p3.FormFactor = "Symmetric"
	p1.Transparency = 1
	p2.Transparency = 1
	p3.Transparency = 1
	p1.CFrame = CFrame.Angles(0,1,0)--this is to prevent things from accidentally welding to it
	p2.CFrame = p1.CFrame*CFrame.new(0,0,-2)
	p3.CFrame = p2.CFrame*CFrame.new(3,1,0)
	p2.BackSurface = "Motor"
	p2:MakeJoints()--makes sure that the unanchored parts don't fall apart
	p3:MakeJoints()
	local StartPos = p3.Position
	p2:SetNetworkOwner(nil)--make sure a pesky client doesn't get it!
	wait(1)--run the test
	local EndPos = p3.Position--test is over!
	local Magnitude = (EndPos-StartPos).magnitude--how much did the brick move?
	local PGSPhysicsSolverEnabledValue = Instance.new("BoolValue")
	PGSPhysicsSolverEnabledValue.Name = "PGSPhysicsSolverEnabled"
	PGSPhysicsSolverEnabledValue.Value = (Magnitude < 0.2) and true or false--if the brick moved a lot, then it's in Spring Physics
	PGSPhysicsSolverEnabledValue.Parent = game.ServerScriptService--let everyone else who was waiting know the outcome
	PGSTemp:Destroy()--this would cause major problems if it wasn't destroyed
	p1:Destroy()--clean up the test
	p2:Destroy()
	p3:Destroy()
	return Magnitude < 0.2--tell our script what the answer is
end