So i got this problem.
math.random
is returning the same value in a loop every time the loop is called.
Video of the problem:
you see how the bars are all moving with each other? I want that to be more random. Here is my script:
while true do
local randomSong = songs[math.random(1,#songs)] --disregard this; for my custom song choosing system
randomSong:Play()
randomSong.Playing = true
titleLabel.Text = randomSong.Title.Value
artistLabel.Text = randomSong.Artist.Value
wait(.1)
while randomSong.Playing == true do --I use "while do" here
local cam = workspace.CurrentCamera
cam.FieldOfView = randomSong.PlaybackLoudness/160+70 --Pulsing the camera. Works perfectly.
while wait() do --Each label's size is being changed... by the same value? here is where I think it is messing up \/
script.Parent.Parent.EQ.neg35.Size = UDim2.new(.166,0, randomSong.PlaybackLoudness/190*math.random(1.02,1.5) + math.random(.039,.845),0)
script.Parent.Parent.EQ.neg25.Size = UDim2.new(.166,0, randomSong.PlaybackLoudness/195*math.random(1.02,1.5) + math.random(.039,.845),0)
script.Parent.Parent.EQ.neg5.Size = UDim2.new(.166,0, randomSong.PlaybackLoudness/200*math.random(1.02,1.5) + math.random(.039,.845),0)
script.Parent.Parent.EQ.pos5.Size = UDim2.new(.166,0, randomSong.PlaybackLoudness/210*math.random(1.02,1.5) + math.random(.039,.845),0)
script.Parent.Parent.EQ.pos25.Size = UDim2.new(.166,0, randomSong.PlaybackLoudness/230*math.random(1.02,1.5) + math.random(.039,.845),0)
script.Parent.Parent.EQ.pos35.Size = UDim2.new(.166,0, randomSong.PlaybackLoudness/220*math.random(1.02,1.5) + math.random(.039,.845),0)
end --Dont think I actually need the "while wait() do"
if randomSong.TimePosition == 0 then --disregard
randomSong.Playing = false
end
wait()
end
wait(3)
end
the non-included variables do not matter right now.