Max size for bubble/ballon

hello so i am work on bubble/ballon like inside bubble gum simulator and i am have no idea how to set the max size for the ballon inside the game here is the scripts:

1 - BallTexture)
game.Workspace.Events.BallonTexture.OnServerEvent:Connect(function(plr)
while wait(0.01) do

	if plr.Hidden.BubbleTexture.Value == 0 then
		script.Parent.Color = Color3.fromRGB(9,137,207)
		script.Parent.Material = Enum.Material.SmoothPlastic
		plr.Flover.FloverValue.Value = 0.2
	end
	
	if plr.Hidden.BubbleTexture.Value == 1 then
		script.Parent.Color = Color3.fromRGB(9,137,207)
		script.Parent.Material = Enum.Material.Neon
		plr.Flover.FloverValue.Value = 1
	end
	
	if plr.Hidden.BubbleTexture.Value == 2 then
		script.Parent.Color = Color3.fromRGB(207,137,9)
		script.Parent.Material = Enum.Material.Neon
		plr.Flover.FloverValue.Value = 5
	end
	
	if plr.Hidden.BubbleTexture.Value == 3 then
		script.Parent.Color = Color3.fromRGB(255, 0, 191)
		script.Parent.Material = Enum.Material.Neon
		plr.Flover.FloverValue.Value = 15
	end
	
	if plr.Hidden.BubbleTexture.Value == 4 then
		script.Parent.Color = Color3.fromRGB(0, 255, 0)
		script.Parent.Material = Enum.Material.Neon
		plr.Flover.FloverValue.Value = 45
	end
	
	if plr.Hidden.BubbleTexture.Value == 4 or plr.Hidden.BubbleTexture.Value >= 4 then
		script.Parent.Color = Color3.fromRGB(128, 187, 219)
		script.Parent.Material = Enum.Material.Granite
		plr.Flover.FloverValue.Value = 98
	end
	
end

end)

2 - SizeAndGravity)
game.Players.PlayerAdded:Connect(function()
script.Parent.Size = Vector3.new(0.05,0.05,0.05)
end)

game.Workspace.Events.BlowingBallon.OnServerEvent:Connect(function(plr)
while wait(0.01) do
script.Parent.Parent.Parent.Humanoid.JumpPower = plr.Hidden.Ballons.Value
script.Parent.Size = Vector3.new(plr.Hidden.Ballons.Value / 5,plr.Hidden.Ballons.Value / 5,plr.Hidden.Ballons.Value / 5)
script.Parent.SurfaceGui.TextLabel.Text = plr.Hidden.Ballons.Value
script.Parent.Parent.AttachmentUp = Vector3.new(0,1,0)
script.Parent.Parent.AttachmentRight = Vector3.new(1,0,0)
script.Parent.Parent.AttachmentPos = Vector3.new(0,0,0)
script.Parent.Parent.AttachmentForward = Vector3.new(0,0,-1)
if script.Parent.Parent.Parent.Humanoid.JumpPower >= 350 then
script.Parent.Parent.Parent.Humanoid.JumpPower = 350
end
end
end)

thanks for the helpers.

Use math.clamp(Ballons, minsize, maxsize )

Also, your code is poorly formatted, and it’s really inefficient. Instead of using so many if statements, just use a dictionary

what you mean by use a dictionary?

and ballons is a number value in leaderstats so that will work?

Yes it will work. And about the dictionary check the devhub tutorial about tables

1 Like

He means something like this:

local textures = {
	{
		color = Color3.fromRGB(9, 137, 207),
		material = Enum.Material.SmoothPlastic,
		flovervalue = 0.2
	},
	{
		color = Color3.fromRGB(9, 137, 207),
		material = Enum.Material.Neon,
		flovervalue = 1
	},
	{
		color = Color3.fromRGB(207, 137, 9),
		material = Enum.Material.Neon,
		flovervalue = 5
	},
	{
		color = Color3.fromRGB(255, 0, 191),
		material = Enum.Material.Neon,
		flovervalue = 15
	},
	{
		color = Color3.fromRGB(0, 255, 0),
		material = Enum.Material.Neon,
		flovervalue = 45
	},
	{
		color = Color3.fromRGB(128, 187, 219),
		material = Enum.Material.Granite,
		flovervalue = 98
	},
	
}

Then you’d update the balloon texure with this line: (Basically replacing that whole nested if statement with this)

-- added the 'math.min' part to account for the >=4 condition
local index = math.min(plr.Hidden.BubbleTexture.Value, 5) + 1
script.Parent.Color = textures[index].color
script.Parent.Material = textures[index].material
plr.Flover.FloverValue = textures[indes].flovervalue
2 Likes

ok thx but can you just tell where i am need to add that? to which script of them…

and that no works dude.


theres is your script:
local textures = {
{
color = Color3.fromRGB(9, 137, 207),
material = Enum.Material.SmoothPlastic,
flovervalue = 0.2
},
{
color = Color3.fromRGB(9, 137, 207),
material = Enum.Material.Neon,
flovervalue = 1
},
{
color = Color3.fromRGB(207, 137, 9),
material = Enum.Material.Neon,
flovervalue = 5
},
{
color = Color3.fromRGB(255, 0, 191),
material = Enum.Material.Neon,
flovervalue = 15
},
{
color = Color3.fromRGB(0, 255, 0),
material = Enum.Material.Neon,
flovervalue = 45
},
{
color = Color3.fromRGB(128, 187, 219),
material = Enum.Material.Granite,
flovervalue = 98
},

}

game.Workspace.Events.BallonTexture.OnServerEvent:Connect(function(plr)
– added the ‘math.min’ part to account for the >=4 condition
local index = math.min(plr.Hidden.BubbleTexture.Value, 5) + 1
script.Parent.Color = textures[index].color
script.Parent.Material = textures[index].material
plr.Flover.FloverValue = textures[index].flovervalue
end)

I gave you pseudo-code; you were supposed to analyze it and apply it to the task you are trying to do, not just copy and paste and expect it to work with no issues.

It just looks like there’s a spelling mistake. You typed in “FloverValue” in your original script so that’s what I thought you meant to name it. I’m guessing you meant “FlavorValue” or something?

Also in future posts could you format your code with ``` before and after to make it easier to read?

like this

i meant on flover to FlavorValue

FlavorValue is the amount of how much player will get per click.