I'm trying to make a "Random even script" in where it takes a random gui from Lighting, clones it, then parents it to startergui. For some reason it wont work pls help.
-- Just Place this in game.Workspace and edit like you need -- Made by DraketehDark wait(0.5) --Half a sec? while true do local i = math.random(1) wait(i * 10) --Time to wait between events i = math.random(1) --Change value if you need more events --First Event if i == 1 then wait(3) local m = game.Lighting.Randomgui:Clone()--Change ??? to whatever the model's name and it MUST be in Lighting m.Parent = game.StarterGui --2nd Event end end
---- Create a folder inside lighting and place all of your gui's in it. local rng = Random.new() -- Random is supposedly faster, and more efficient than math.random local guis = game.Lighting.Guis:GetChildren() -- Create a table with all the guis in it. local gui = guis[rng:NextInteger(1,#guis)]:Clone() -- randomly selects a gui from the table. Table[index] will return whatever is in a table with that index, so calling guis[index], however since you want it random you can use Random:NextInteger(min,max) or (1,#items in table) ----- Are you trying to parent it to startergui, so all players get it when they spawn? if so, gui.Parent = game.StarterGui ---Or are you trying to parent it to a player so he has it immediately? if so, gui.Parent = player.PlayerGui
This should work.
EDIT for typo