I am making a screensaver (Yes, I know) and I need it to travel to a random position every five seconds. The problem is, math.random doesn't do decimals, making the script useless.
while true do math.randomseed(tick()) local ab = math.random(0,7) local ac = math.random(0,5) script.Parent:TweenPosition(UDim2.new(0.ab, 0,0.ac, 0), "InOut", "Quad", 5) wait(5) end
Try math.random() * some number instead. math.random(number1, number2) only returns integers within the range number1 <= x <= number2. math.random() returns a decimal in the range 0, 1. You can multiply this to get decimals between 0 and the number you multiply it by.
while true do math.randomseed(tick()) local ab = math.random() * 7 local ac = math.random() * 5 script.Parent:TweenPosition(UDim2.new(0.ab, 0,0.ac, 0), "InOut", "Quad", 5) wait(5) end
Oops! Sorry! I thought I could never figure this one out but I did! If you think this code has something wrong with it, please let me know!
while true do math.randomseed(tick()) local ad = math.random(0,7) local ae = math.random(0,5) local ab = ad / 10 local ac = ae / 10 script.Parent:TweenPosition(UDim2.new(ac , 0, ac, 0), "InOut", "Quad", 5) wait(5.1) end