Need help with balloon script

Hey y’all! For some reason, my balloon script isn’t working. The balloon just doesn’t levitate when I jump with it, but is in my inventory. I apologize if I didn’t explain the issue correctly, I’m new to all this. I’ve tried changing the numbers/editing the script, but no luck. If anyone could help me, that would be great and appreciated.

local Tool = script.Parent
local upAndAway = false
local humanoid = nil
local head = nil
local upAndAwayForce = Instance.new(“BodyForce”)

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

local height = nil
local maxRise = 25

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,0)
Tool.GripUp = Vector3.new(0, 1, 0.005)
height = Tool.Parent.UpperTorso.Position.y
local lift = recursiveGetLift(Tool.Parent)
float(lift)

end

function onUnequipped()

upAndAway = false
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 > 100 then
	Tool.Handle.Mesh.Scale = Vector3.new(1,1,1)
elseif range < 100 and range > 50 then
	Tool.Handle.Mesh.Scale = Vector3.new(2,2,2)
elseif range < 50 then
	Tool.Handle.Mesh.Scale = Vector3.new(3,3,3)
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

Are there any errors in console?

LuaWebService error seems to be just roblox having issues

Oh, idk if that’s related to the balloon script thing though. Like the issue I’m having with the balloon is it basically not flying even though it’s supposed to when I jump with it

I don’t see float function getting executed anywhere in script? Correct me if I’m wrong

I’m not the best at scripting as it confuses me a lot, but I see that there’s a gravity/local equalizingforce which I think has something to do with it. But then again, there’s also other things in the script that I also don’t understand… sorry I’m new to all this lol

First, UpAndAway Instance is defined once in a script (in the beginning), so when it can be used only once and I don’t see “node” variable defind anywhere?

Second you could try

Humanoid.StateChanged:Connect(function(old, new)
	if new == Enum.HumanoidStateType.FreeFalling then
		-- you execute your lift function 
	end
end)

Documentation:

Do you know where exactly I would put that btw?

You need to put it in a script. But you also need to define Humanoid variable. If you don’t know anything about Lua i advise you to read roblox documentation or watch some YouTube tutorials or read other people’s scripts.

Roblox Creator Documentation ← there is a lot of helpful information in there.

1 Like

Thanks! I appreciate your help

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.