How I Can Use Random On Frames?

**Hello, My Name Is Nehoray **
Currently I’m Working On A New Game And I wanted To Know How I Can Use Random On Frames
Like When I’m Pressing A Button It Will Display Randomly Frame That I Created Previously And Stored In ServerStorage
Any Help Will Be Appreciated!

There is one problem with what you’re trying to do:

Solution: Store in Client Side or simply somewhere near The Script

You should store all Frames in a table for eg

local FrameTable = game[StoragePath]:GetChildren() --for eg game.ServerStorage:GetChildren()

local RandomFrame = FrameTable[math.random(1,#FrameTable)]

This will randomly take a frame as input

2 Likes

I’m Doing This From Server-Side But Thanks I will Check it out! :grinning:

Unless you have a weird way of replicating UI, handling UI should always happen from the client. Instead you could store them in ReplicatedStorage, or very simply have them parented to their parent Frame or ScreenGui or something, and make the chosen frame the visible one, instead of copying it from the storage container and parenting it.

You shouldn’t Handle Ui from Server its not very much recommended and it will just be too much hard if not impossibe

Ok I will try To Do Something! Thanks

The best solution is to just put it somewhere near script and use the table script:

local FrameTable = game[StoragePath]:GetChildren() --for eg game.ServerStorage:GetChildren()

local RandomFrame = FrameTable[math.random(1,#FrameTable)]

RandomFrame.Visible = true