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 9 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?

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

4 answers

Log in to vote
0
Answered by 9 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:

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

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