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
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
lol = website[math.random(1, #website)] while true do [lol].Visible = true wait(5) [lol].Visible = false end
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
Your original script was actually correct, but for additional randomness, you could add the line
math.randomseed(tick())
to your script.