Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

2 comments

0

hope this helps

0

Thank you!

This discussion is preserved as it was. New answers, comments, and votes are closed.