local K=script.Parent local r=false local N=nil local m=nil local F=K.Handle.BodyForce isfloating=false local R=196.66666666667 local s=1.05 local d=nil local c=75 function onEquipped()K.Handle.Mesh.MeshId="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\050\053\052\057\056\053\054\053"equipped=true K.GripPos=Vector3.new(0,-1,0)K.GripForward=Vector3.new(0,1,0)K.GripRight=Vector3.new(0,0,-1)K.GripUp=Vector3.new(1,0,0)d=K.Parent.Torso.Position.y lift=recursiveGetLift(K.Parent)float(lift)end function onUnequipped()equipped=false K.GripForward=Vector3.new(1,0,0)K.GripRight=Vector3.new(0,0,1)K.GripUp=Vector3.new(0,1,0)K.Handle.Mesh.Scale=Vector3.new(1,1,1)end K.Unequipped:connect(onUnequipped)K.Equipped:connect(onEquipped)K.Handle.Touched:connect(onTouched)function recursiveGetLift(K)local r=0 local N=K:GetChildren()if K:FindFirstChild("\072\101\097\100")~=nil then m=K:FindFirstChild("\072\101\097\100")end for K=1,#N,1 do if N[K].className=="\080\097\114\116"then if m~=nil and(N[K].Position-m.Position).magnitude<10 then if N[K].Name=="\072\097\110\100\108\101"then r=r+(N[K]:GetMass()*R)*1 else r=r+(N[K]:GetMass()*R)*s end end end r=r+recursiveGetLift(N[K])end return r end function updateBalloonSize()local r=(d+c)-K.Handle.Position.y if r<(c/3)*1 then K.Handle.Mesh.Scale=Vector3.new(3,3,3)elseif r<(c/3)*2 then K.Handle.Mesh.Scale=Vector3.new(2,2,2)else K.Handle.Mesh.Scale=Vector3.new(1,1,1)end end function float(r)if not isfloating then isfloating=true while equipped do r=recursiveGetLift(K.Parent)F.force=Vector3.new(0,r*.8,0)wait(.2)if K.Handle.Position.y>300 then equipped=false K.Handle.Pop:Play()K.GripPos=Vector3.new(0,-0.4,0)K.Handle.Mesh.MeshId="\104\116\116\112\058\047\047\119\119\119\046\114\111\098\108\111\120\046\099\111\109\047\097\115\115\101\116\047\063\105\100\061\050\054\055\050\053\053\049\048"end updateBalloonSize()end F.force=Vector3.new(0,0,0)isfloating=false end end
--

local Tool = script.Parent
local upAndAway = false
local humanoid = nil
local head = nil
local upAndAwayForce = Tool.Handle.BodyForce
isfloating = false

local equalizingForce = 236 / 1.2 -- amount of force required to levitate a mass
local gravity = 1.05 -- things float at > 1

local height = nil
local maxRise = 75

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

function onUnequipped()
	equipped = 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(1, 1, 1)
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
	if range < (maxRise / 3) * 1 then
		Tool.Handle.Mesh.Scale = Vector3.new(3, 3, 3)
	elseif range < (maxRise / 3) * 2 then
		Tool.Handle.Mesh.Scale = Vector3.new(2, 2, 2)
	else
		Tool.Handle.Mesh.Scale = Vector3.new(1, 1, 1)
	end
end

function float(lift)
	if not isfloating then
		isfloating = true
		while equipped do
			lift = recursiveGetLift(Tool.Parent)
			upAndAwayForce.force = Vector3.new(0, lift * 0.8, 0)
			wait(0.2)
			--if Tool.Handle.Position.y > height + maxRise then
			if Tool.Handle.Position.y > 300 then
				equipped = false
				Tool.Handle.Pop:Play()
				Tool.GripPos = Vector3.new(0, -0.4, 0)
				Tool.Handle.Mesh.MeshId = "http://www.roblox.com/asset/?id=26725510"
			end
			updateBalloonSize()
		end
		upAndAwayForce.force = Vector3.new(0, 0, 0)
		isfloating = false
	end
end
