local C=150.0 local s=1.05 local p=nil local A=10 function onTouched(C)local s=C.Parent:FindFirstChild("\072\117\109\097\110\111\105\100")if s~=nil then upAndAway=true Tool.Handle.Anchored=false end end function onEquipped()upAndAway=true upAndAwayForce.Parent=Tool.Handle Tool.GripPos=Vector3.new(0,-1.75,0)Tool.GripForward=Vector3.new(0,1,0)Tool.GripRight=Vector3.new(0,0,-1)Tool.GripUp=Vector3.new(0,2,0)p=Tool.Parent.HumanoidRootPart.Position.y local C=recursiveGetLift(Tool.Parent)float(C)end function onUnequipped()upAndAway=false Tool.GripForward=Vector3.new(1,0,0)Tool.GripRight=Vector3.new(0,0,1)Tool.GripUp=Vector3.new(0,1,0)Tool.Handle.Mesh.Scale=Vector3.new(.02,.02,.02)end Tool.Unequipped:connect(onUnequipped)Tool.Equipped:connect(onEquipped)Tool.Handle.Touched:connect(onTouched)function recursiveGetLift(p)local A=0 local E=p:GetChildren()if p:FindFirstChild("\072\101\097\100")~=nil then head=p:FindFirstChild("\072\101\097\100")end for p=1,#E,1 do if E[p].className=="\080\097\114\116"then if head~=nil and(E[p].Position-head.Position).magnitude<10 then if E[p].Name=="\072\097\110\100\108\101"then A=A+(E[p]:GetMass()*C)*1 else A=A+(E[p]:GetMass()*C)*s end end end A=A+recursiveGetLift(E[p])end return A end function updateBalloonSize()local C=(p+A)-Tool.Handle.Position.y print(C)if C>100 then Tool.Handle.Mesh.Scale=Vector3.new(.03,.03,.03)elseif C<100 and C>50 then Tool.Handle.Mesh.Scale=Vector3.new(.025,.025,.025)elseif C<50 then Tool.Handle.Mesh.Scale=Vector3.new(.02,.02,.02)end end function float(C)while upAndAway do upAndAwayForce.force=Vector3.new(0,C*.98,0)upAndAwayForce.Parent=Tool.Handle wait(3)upAndAwayForce.force=Vector3.new(0,C*.92,0)wait(2)if Tool.Handle.Position.y>p+A then upAndAway=false Tool.Handle.Pop:Play()Tool.GripPos=Vector3.new(0,-0.4,0)upAndAwayForce.Parent=nil end updateBalloonSize()end end
--local equalizingForce = 236 / 1.2 -- amount of force required to levitate a mass
local equalizingForce = 180 / 1.2 -- amount of force required to levitate a mass
local gravity = 1.05 -- things float at > 1

local height = nil
local maxRise = 10

function onTouched(part)
	local h = part.Parent:FindFirstChild("Humanoid")
	if h ~= nil then
		upAndAway = true
		Tool.Handle.Anchored = false
	end
end

function onEquipped()
	--Tool.Handle.Mesh.MeshId = "http://www.roblox.com/asset/?id=25498565"
	upAndAway = true
	upAndAwayForce.Parent = Tool.Handle
	Tool.GripPos = Vector3.new(0, -1.75, 0)
	Tool.GripForward = Vector3.new(0, 1, 0)
	Tool.GripRight = Vector3.new(0, 0, -1)
	Tool.GripUp = Vector3.new(0, 2, 0)
	height = Tool.Parent.HumanoidRootPart.Position.y
	local lift = recursiveGetLift(Tool.Parent)
	float(lift)
end

function onUnequipped()
	upAndAway = false
	Tool.GripForward = Vector3.new(1, 0, 0)
	Tool.GripRight = Vector3.new(0, 0, 1)
	Tool.GripUp = Vector3.new(0, 1, 0)
	Tool.Handle.Mesh.Scale = Vector3.new(0.02, 0.02, 0.02)
end

Tool.Unequipped:connect(onUnequipped)
Tool.Equipped:connect(onEquipped)
Tool.Handle.Touched:connect(onTouched)

function recursiveGetLift(node)
	local m = 0
	local c = node:GetChildren()
	if node:FindFirstChild("Head") ~= nil then
		head = node:FindFirstChild("Head")
	end -- nasty hack to detect when your parts get blown off

	for i = 1, #c do
		if c[i].className == "Part" then
			if head ~= nil and (c[i].Position - head.Position).magnitude < 10 then -- GROSS
				if c[i].Name == "Handle" then
					m = m + (c[i]:GetMass() * equalizingForce * 1) -- hack that makes hats weightless, so different hats don't change your jump height
				else
					m = m + (c[i]:GetMass() * equalizingForce * gravity)
				end
			end
		end
		m = m + recursiveGetLift(c[i])
	end
	return m
end

function updateBalloonSize()
	local range = (height + maxRise) - Tool.Handle.Position.y

	print(range)

	if range > 100 then
		Tool.Handle.Mesh.Scale = Vector3.new(0.03, 0.03, 0.03)
	elseif range < 100 and range > 50 then
		Tool.Handle.Mesh.Scale = Vector3.new(0.025, 0.025, 0.025)
	elseif range < 50 then
		Tool.Handle.Mesh.Scale = Vector3.new(0.02, 0.02, 0.02)
	end
end

function float(lift)
	while upAndAway do
		upAndAwayForce.force = Vector3.new(0, lift * 0.98, 0)
		upAndAwayForce.Parent = Tool.Handle
		wait(3)

		upAndAwayForce.force = Vector3.new(0, lift * 0.92, 0)
		wait(2)

		if Tool.Handle.Position.y > height + maxRise then
			upAndAway = false
			Tool.Handle.Pop:Play()
			Tool.GripPos = Vector3.new(0, -0.4, 0)
			--Tool.Handle.Mesh.MeshId = "http://www.roblox.com/asset/?id=26725510"
			upAndAwayForce.Parent = nil
		end

		updateBalloonSize()
	end
end
