So i am doing a minigame script, trying to have it so it will randomly choose a model with in Lighting but when i look up "ROBLOX Random Lua" or something like that it doesn't return any results that will help me, so i was doing the
if #game.Players:GetChildren() == 5 then local message = Instance.new('Message', game.Workspace) message.Text = ("Starting Game!") -- Random Choice Map Here with text spamming through the name of the maps (model name)
Thanks in advance
local maps = game.Lighting:GetChildren() -- I would put the maps somewhere more specific, like game.ReplicatedStorage.Maps local randomMap = maps[math.random(#maps)] -- This is now your randomly selected map randomMap.Parent = game.Workspace randomMap:MakeJoints()
I'm confused by your question... Also messages are outdated and you should probably use GUIs and Server/ReplicatedStorage instead of lighting.
If you want to clone a model into the workspace then:
local maps = { "Map name", "Other map name" } if game.Players.NumPlayers >= 5 then local map = game.ServerStorage[maps[math.random(1, #maps)]]:Clone() map:MoveTo(Vector3.new(0,0,0)) --Position the model wherever you want. end
So right now this is my code, was wondering why a message isn't being created when 1 player is in the game. Do i have to test in a full server mode or can i test in solo?
local maps = { "Test" } if #game.Players:GetChildren() == 1 then local message = Instance.new('Message', game.Workspace) message.Text = "Starting Game!" wait(1) message:destroy() local map = game.Lighting[maps[math.random(1, #maps)]]:Clone() map:MoveTo(Vector3.new(123, 1.8, 190.5)) --Position the model wherever you want. end