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

How can I detect if a player has CLICKED ALL the things in a table?

Asked by 4 years ago
local egg1 = game.Workspace["Egg 1"]
local egg2 = game.Workspace["Egg 2"]
local egg3 = game.Workspace["Egg 3"]
local egg4 = game.Workspace["Egg 4"]
local egg5 = game.Workspace["Egg 5"]
local egg6 = game.Workspace["Egg 6"]
local egg7 = game.Workspace["Egg 7"]
local egg8 = game.Workspace["Egg 8"]
local egg9 = game.Workspace["Egg 9"]
local egg10 = game.Workspace["Egg 10"]

local eggtable = {egg1,egg2,egg3,egg4,egg5,egg6,egg7,egg8,egg9,egg10}

^ Is what I have so far but I don't know how to detect if all those things have been clicked or not.

1 answer

Log in to vote
0
Answered by
Hydrogyn 155
4 years ago

affects all players in the server btw

assuming that you put a click detector in all of the eggs, add a bool value into the egg and name it "clicked".

also, create a folder in the workspace and name it "Eggs" and then put all of the eggs into there!

next, make a script so when the player clicks the egg the bool value "clicked" will turn true!

(incase you dont know how)

script.Parent.ClickDetector.MouseClick:connect(function()
    script.Parent.clicked.Value = true
end)

Now for the rest!

for a,b in pairs(game.Workspace.Eggs:GetChildren()) do -- getting all of the children of "Eggs"
    if b.clicked.Value == true then 
        print("all the eggs have been clicked!")
        -- rest of the code
    end
end

// hydrogyn, 4/12/2020

0
hope this helps Hydrogyn 155 — 4y
0
Thank you! ivan08pr -3 — 4y
Ad

Answer this question