Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Random seed within a boundary?

Asked by
NotSoNorm 777 Moderation Voter
10 years ago

I'm trying to make it so it will return a random number with in a 0 to a (-800) range, How would I do this? This is what I have so far:

while true do
    NUM1:TweenSize(UDim2.new(0, 100,0,math.random()),"Out","Linear",0.05,false)
    wait(0.2)
end
0
Are you the person that was asking about the music - equalizer GUI thing a min ago? Azarth 3141 — 10y

1 answer

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
10 years ago
NUM1:TweenSize(UDim2.new(0, 100,0,math.random(-800,0)),"Out","Linear",0.05,false)

If you're the equalizer guy, I wrote you a demo;

-- Put a LocalScript in to a ScreenGui

local num_bars = 30
-- How many bars?
local bar_width = 20
local container_color = BrickColor.new("Institutional white")
local bar_color = BrickColor.new("Really black")
local max_bar_height = 200
local min_bar_height = 3
local tween_speed = .5
-- How fast they go up and down


-- Just something that creates the GUI's 
local function create(instanc)
    return function(info)
        local new = Instance.new(instanc)
        for i,v in pairs(info) do 
            new[i] = v
        end
        return new
    end
end

-- This is your background
local container = create("Frame")
{
    Size = UDim2.new(0,(num_bars*bar_width) + num_bars,0,max_bar_height);
    Position = UDim2.new(.5,-((num_bars*bar_width)/2),.5,-(max_bar_height/2));
    BackgroundTransparency = 0;
    BackgroundColor = container_color;
    BorderSizePixel = 3;
    Parent = script.Parent
}

-- These are your bars
for i = 1, num_bars do 
    local bar = create("Frame")
    {
        Size = UDim2.new(0,bar_width,0,0);
        Position = UDim2.new(0,((i-1)*bar_width) + i,0,container.Size.Y.Offset);
        Name = "bar"..i;
        BorderColor = container_color;
        BorderSizePixel = padding;
        BackgroundColor = bar_color;
        Parent = container
    }
    -- This runs more than one while statement at once
    Spawn(function()
        while true do
            local random_size_y = math.random(min_bar_height, max_bar_height)
            bar:TweenSize(UDim2.new(0,bar_width,0,-random_size_y),"Out", "Linear", tween_speed, true)
            wait(tween_speed)
        end
    end)
end
0
I'm on too late to answer questions, just got be quicker.. HexC3D 830 — 10y
0
What? Azarth 3141 — 10y
Ad

Answer this question