so im trying to make my attachments be positioned randomly between -3 and 3 studs on the x and y axis of my attachment’s cframe if that makes sense. the problem is is that the attachments are going in a straight line.

this line i believe is the problem but i’m not sure how to fix it:

```
attachment.CFrame = b2a.CFrame + b2a.CFrame.LookVector * Vector3.new(randomX,randomY,lastnumber)
```

```
local b1, b2 = workspace.b1, workspace.b2
local b1a, b2a = b1.b1, b2.b2
local b1b2Distance = ((b1.Position - b2.Position).Magnitude) - 3.5
local direction = (b2.Position-b1.Position)
local beam = b1.Beam
local randomNumberTable = {}
local lastnumber = 0
local function randomNumber()
for i = 1,10 do
local random = Random.new()
local randomNumber = random:NextNumber(1.5, b1b2Distance/8)
local randomX, randomY = random:NextNumber(-3, 3)
lastnumber += randomNumber
print(i..": "..lastnumber)
local attachment = Instance.new("Attachment", b2)
attachment.Name = "attachment".."_"..i
attachment.CFrame = b2a.CFrame + b2a.CFrame.LookVector * Vector3.new(randomX,randomY,lastnumber)
wait(.25)
end
end
```

you forgot to set the y variable, try copy pasting the x variable to the y variable.

1 Like

hey skelly,

thanks for your help mate. i tried this a few minutes ago and i’m still getting the same result if that was what u were on about unfortunately

```
local randomX, randomY = random:NextNumber(-3, 3), random:NextNumber(-3, 3)
```

Im at a loss then, maybe if you tried setting the variables separately that could work, if it doesn’t I have no idea.

1 Like

thats no worries mate, i just found out how to do it by winging it. thanks for the help anyways!!

i only changed these 2 lines of code to this and it worked:

```
local randomX, randomY = random:NextNumber(-3, 3), random:NextNumber(-3, 3)
```

```
attachment.CFrame = b2a.CFrame + b2a.CFrame.LookVector - Vector3.new(randomX,randomY,lastnumber)
```

solution:

```
local b1, b2 = workspace.b1, workspace.b2
local b1a, b2a = b1.b1, b2.b2
local b1b2Distance = ((b1.Position - b2.Position).Magnitude) - 3.5
local direction = (b2.Position-b1.Position)
local beam = b1.Beam
local randomNumberTable = {}
local lastnumber = 0
local function randomNumber()
for i = 1,10 do
local random = Random.new()
local randomNumber = random:NextNumber(1.5, b1b2Distance/8)
local randomX, randomY = random:NextNumber(-3, 3), random:NextNumber(-3, 3)
lastnumber += randomNumber
print(i..": "..lastnumber)
local attachment = Instance.new("Attachment", b2)
attachment.Name = "attachment".."_"..i
attachment.CFrame = b2a.CFrame + b2a.CFrame.LookVector - Vector3.new(randomX,randomY,lastnumber)
wait(.25)
end
end
randomNumber()
```