Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make a GUI that is randomly selected then removed from table?

Asked by 3 years ago

How exactly would I go about in order to make it so I have a table of several GUIs all containing different text, then have them be selected at random, have the player have to click something in the world using click detector to get the answer correct, then have that gui removed so that it can not be selected again even if they get the answer incorrect, and move on to the remaining GUIs? If anyone can give me pointers or tips on how I would go about to get this done, I'd greatly appreciate it! Thanks.

math.randomseed(tick())
local client = game:GetService("Players").LocalPlayer

local pumkin = game.Workspace.Dummy
local pumkin_posC = game.Workspace.PointC
-- Foods in starter gui-----------------------------------------------------------------------
local burgerG = script.Parent.Parent.Parent.Burger.Text
local hotdogG = script.Parent.Parent.Parent.Hotdog.Text
local breadG = script.Parent.Parent.Parent.Bread.Text
local chickenG = script.Parent.Parent.Parent.Chicken.Text
local cheeseG = script.Parent.Parent.Parent.Cheese.Text
local frenchfriesG = script.Parent.Parent.Parent.FrenchFries.Text
local juiceG = script.Parent.Parent.Parent.Juice.Text
local pizzaG = script.Parent.Parent.Parent.Pizza.Text
local sodaG = script.Parent.Parent.Parent.Soda.Text
local butterG = script.Parent.Parent.Parent.Butter.Text
local eggG = script.Parent.Parent.Parent.Egg.Text
local saltG = script.Parent.Parent.Parent.Salt.Text
local pepperG = script.Parent.Parent.Parent.Pepper.Text
local sandwichG = script.Parent.Parent.Parent.Sandwich.Text
---------------------------------------------------------------------------------
--Food models in a array table
---------------------------------------------------------------------------------
local foodMtable = game.Workspace.Foods:GetChildren()




local function pumkindiag1(other_part)
    local humanoid = other_part.Parent:FindFirstChild("Humanoid")
    if humanoid ~= nil then
        script.Parent.Visible = true
        wait(3)
        print("Here he is!")
        script.Parent.Visible = false
    end
end

local function pumpkinchoices()
    local foodIndex = math.random(#foodMtable)
    local foodSelected = table.remove(foodMtable, foodIndex)
    print(foodSelected)
end


wait()
pumkin_posC.Touched:Connect(pumkindiag1)
wait(1)
pumpkinchoices()

Answer this question