How do I name Parts that are made by a pair to be named after what number they are in the pair?

So I have a system that automatically makes 3-5 Parts with balloon billboardgui’s that float around randomly. The problem is I need another script to detect how many of each color there are, Which I’m sure I can figure out on my own.

But the problem is all the balloons are named the same thing, so another script can’t access all of them. So how would I go about having the Parts be named after what number they are in the pair?

Here is the pair script snippet

if modeswitch == 2 then
	local LimitBox = script.Parent
	local BounariesX = LimitBox.Size.X
	local BounariesY = LimitBox.Size.Y
	local BounariesZ = LimitBox.Size.Z

	local Tweens = game:GetService("TweenService")
	local Cloud -- the cloud part, if the cloud is a model then you'd better off using runservice and :PivotTo()

	--Balloon Config

	--Balloon 1
	local Ballons = {}
	for i = 0, math.random(3,5), 1 do --Edit the middle number for the amount of ballons you want
		local Balloon1 = Instance.new("Part")

		local boardgui = Instance.new("BillboardGui")
		boardgui.Size = UDim2.new(10,0,10,0)
		boardgui.Parent = Balloon1

		local spray = Instance.new("ImageLabel")
		spray.BackgroundTransparency = 1
		spray.Size = UDim2.new(1.25,0,1.25,0)
		local rng1 = math.random(1,5)
		if rng1 == 1 then
			spray.Image = 'http://www.roblox.com/asset/?id=18670766961' -- Blue Baldoon rbxassetid://18670766961
		elseif rng1 == 2 then
			spray.Image = 'http://www.roblox.com/asset/?id=18670766814' -- Green Baldoon rbxassetid://18670766814
		elseif rng1 == 3 then
			spray.Image = 'http://www.roblox.com/asset/?id=18670766673' -- Orange Baldoon rbxassetid://18670766673
		elseif rng1 == 4 then
			spray.Image = 'http://www.roblox.com/asset/?id=18670766561' -- Purple Baldoon rbxassetid://18670766561
		elseif rng1 == 5 then
			spray.Image = 'http://www.roblox.com/asset/?id=18670766440' -- Red Baldoon rbxassetid://18670766440
		end
		
		local color = Instance.new("IntValue")
		color.Value = rng1
		color.Parent = Balloon1
		
		spray.Parent = boardgui
		spray.ResampleMode = Enum.ResamplerMode.Pixelated

		Balloon1.Name = "Balloon-"
		
		Balloon1.Transparency = .5
		Balloon1.Color = Color3.new(1, 0, 0.0156863)
		Balloon1.Parent = script.Parent
		Balloon1.Position = (LimitBox.CFrame + (LimitBox.CFrame.RightVector * math.random(-LimitBox.Size.X/2,LimitBox.Size.X/2)) + (LimitBox.CFrame.LookVector * math.random(-LimitBox.Size.Z/2,LimitBox.Size.Z/2))).p 
		Balloon1.Size = Vector3.new(1, 1, 1)
		Balloon1.CanCollide = false
		Balloon1.Anchored = true
		table.insert(Ballons,Balloon1)
	end

Do you mean giving them the # of the order they’re created? If so, you can use the index like this:

Balloon1.Name = "Balloon-"..i

3 Likes

Yup that’s what I mean’t. I knew it was possible I just couldn’t figure it out, Thank you very much!

1 Like

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