so i’m trying to make my random number add each time to the z coordinate of my newAttachment’s cframe. i read up posts about it but i don’t know how to adapt it for my scenario. i appreciate the help ty!!
local function spawnAttachments()
wait(1)
for attachmentVariable = 1, 10 do
local random = Random.new()
local randomNumber = random:NextNumber(lastnumber,b1b2Distance / 10) -- generate random number between (1 and 2.4 ish)
randomNumber += randomNumber
local newAttachment:Attachment = Instance.new("Attachment", b1)
newAttachment.Name = "attachment"..attachmentVariable
newAttachment.CFrame = b1a.CFrame + b1a.CFrame.LookVector * Vector3.new(0,0,lastnumber) -- i want "lastnumber" to increase by the new random number everytime
beam.Attachment0 = newAttachment
beam.Enabled = true
print(attachmentVariable..": "..randomNumber)
wait(.1)
beam.Enabled = false
end
end
What are b1 and b1a? Would be nice if you tell me what those are so so could help you better. Meanwhile try this
local function spawnAttachments()
wait(1)
for attachmentVariable = 1, 10 do
local random = Random.new()
local randomNumber = random:NextNumber(lastnumber,b1b2Distance / 10) -- generate random number between (1 and 2.4 ish)
lastnumber += randomNumber
local newAttachment:Attachment = Instance.new("Attachment", b1)
newAttachment.Name = "attachment"..attachmentVariable
newAttachment.CFrame = b1a.CFrame + (b1a.CFrame.LookVector * lastnumber)
beam.Attachment0 = newAttachment
beam.Enabled = true
print(attachmentVariable..": "..randomNumber)
wait(.1)
beam.Enabled = false
end
end
You gotta increment the last number with the random number and multiply last number by the look vector
You could set the current random number and the next random number. You would need to make the next random number the current random number each time it runs and just make it look something like this.
While true do
Local CurrentRandomNumber = value
Local NextRandomNumber = math.random(0,50)
CurrentRandomNumber = CurrentRandomNumber + NextRandomNumber
wait(1)
end
i decided to scrap what i posted and i started simple instead of jumping the gun. i used some of your code combined with what @baadtiger said and i got it to work how i wanted it to. thanks a million mate, apologies for not posting the rest of the script i completely forgot!!
solution:
local lastnumber = 0
local function randomNumber()
for i = 1,10 do
local random = Random.new()
local randomNumber = random:NextNumber(1, 2.4)
lastnumber += randomNumber
print(i..": "..lastnumber)
wait(.25)
end
end
randomNumber()