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

Picking a random frame making it visible then invisible?

Asked by 8 years ago

Hi I was trying to script a script where it picks a script from random and makes it visible then waits five seconds then goes invisible. Can you help me?

local frame = script.Parent.MainGui.Websites:GetChildren()
while true do
    local find = frame[math.random(1,#frame)]
    find.Visible = true
    wait(1)
    find.Visible = false
end

4 answers

Log in to vote
0
Answered by 8 years ago

All of the recent answers are wrong, because if you declare a variable with a math.random() in it, it will output the same number every time. Also, it would be a lot simpler if you simply used #frame to get how many you want, but this means having the frames as the only children of the parent (this doesn't include descendants). So:

local frame = script.Parent.Parent:GetChildren()
while true do
    local find = frame[math.random(1,#frame)]
    find.Visible = true
    wait(1)
    find.Visible = false
end

In this case, I had 3 frames and the script was in one of the frames, so it wouldn't stuff it up. I tested in studio, and it worked. - TheDeadlyPanther

0
didn't work sorry docrobloxman52 407 — 8y
0
i just edited my code so if you could help me a little for that would be great! docrobloxman52 407 — 8y
0
No wait I was being dumb and had code that didn't belong! thanks m8 docrobloxman52 407 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
lol = website[math.random(1, #website)] 
while true do [lol].Visible = true 
    wait(5) 
    [lol].Visible = false end
0
This will pick the SAME frame each time. Lacryma 548 — 8y
0
It isn't wrong either lol so disregard^ Lacryma 548 — 8y
Log in to vote
0
Answered by
NotSoNorm 777 Moderation Voter
8 years ago
local random = website[math.random(1, #Website)]
while true do
    (Put the path to the frames here)[random].Visible = true
    wait(5)
    (Put the path to the frames here)[random].Visible = false
end
0
explain your answer dingus HungryJaffer 1246 — 8y
0
I did in chat dingus NotSoNorm 777 — 8y
Log in to vote
0
Answered by 8 years ago

Your original script was actually correct, but for additional randomness, you could add the line

math.randomseed(tick())

to your script.

Answer this question