Problem with positioning the parts

Hey,

Basically what I am trying to make is a skill (photos below) I have default row of Butterflies (purple parts) but I want to make it look better so I want to add more butterflies (10-15) but in random positions, so it will look better, a bit above/left/right/down.

the issue with my current script is that it spawns new parts but all of them get stuck together in the middle so all 10new parts are in the middle for some reason.

I first was using CFrame and now I changed to just positions but both of them cause the same issue.

local RS = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Insect = RS:WaitForChild("Insect")


Insect.OnServerEvent:Connect(function(player,Current)
	if Current == "E" and player.TemporaryValues.Using.Value == false and player.TemporaryValues.First.Value == 0 then
		local First = game.ServerStorage.Insect:Clone()
		First.Name = player.Name
		local hrpCFrame = player.Character.HumanoidRootPart.CFrame
		
		
		First:SetPrimaryPartCFrame(hrpCFrame + Vector3.new(0,1,0))
		
		for i = 0,10,1 do 
			local Purple = First.Purple:Clone()
			local Wings = First.Wings:Clone()
			local x = math.random(-10,10)
			local z = math.random(-3,3)
			local y = math.random(-1,1)
			Purple.Parent = First
			Wings.Parent = First
			
			Purple.Position = Vector3.new(hrpCFrame.p + Vector3.new(x,y,z))
			Wings.CFrame = Purple.CFrame

			local Weld = Instance.new("ManualWeld",First.Main)
			Weld.Part0 = First.Main
			Weld.Part1 = Purple

			local Weld2 = Instance.new("ManualWeld",First.Main)
			Weld2.Part0 = First.Main
			Weld2.Part1 = Wings

		end
		First.Parent = workspace
		player.TemporaryValues.Using.Value = true
		player.TemporaryValues.First.Value = 6
		local part = First.Main
		local hrp = player.Character.HumanoidRootPart
        local WaitTime = 0.7

		local goal = {}
		goal.Position = hrpCFrame * Vector3.new(0,0,-60)

		local goal2 = {}
		goal2.Position = hrpCFrame * Vector3.new(0,0,-61)
		
		local tweenInfo = TweenInfo.new(WaitTime,Enum.EasingStyle.Linear,Enum.EasingDirection.Out)

		local tween = TweenService:Create(part, tweenInfo, goal)
		local tween2 = TweenService:Create(hrp, tweenInfo, goal2)
		tween2:Play()
		tween:Play()
		wait(WaitTime)
	--	First:Destroy()
		game.ReplicatedStorage.Insect:FireClient(player)
		player.TemporaryValues.Using.Value = false
	end
end)


^ this is the default row

image
^and this is after the code, parts get stuck in the middle :confused: (the row is fine butterflies are there, but the butterflies which were added from the script gets stuck in the middle)

Going to be honest, I haven’t read the entire code block but I noticed this line of code, which I’m assuming is for your positioning of the butterfly. I think what you’re trying to do is add 2 Vector3s which returns a new Vector3, but you added them inside of the new function. Try this:

Purple.Position = hrp.CFrame.p + Vector3.new(x,y,z)

This adds the random Vector3 to the position of your rootpart, which I believe is what you intend to do. There may be other bugs in the script that I looked over though, do you get any errors when you run the code?

I used your code but the same thing happens.

Does it print any errors in the output?

Nope, it just positions the part in the middle, same thing as before

btw I fixed it (was a small mistake)