Hello
I am currently working on a Simon Says program, and I am having trouble with this checkTouched() function in my main sequence script. Here is some information about how this touch check is supposed to be executed when ran:

Above is a snip of my workspace tree. Inside I have a Colors folder that contains all the color pads and are labeled by their corresponding color. Each color pad has a touchDetect script that is replicated into each color when the game is executed. What the script does is it detects when it is touched and sets the value of recentTouched to its color as a string value. The following is the touchDetect script:
local part = script.Parent
local colors = script.Parent.Parent
local value = script.Parent.Parent.Parent.recentTouched.Value
local color = script.Parent.Name
part.Touched:Connect(function()
print("Player Touched " .. color .. "!")
value = color
print("Touched value is now: " .. value)
end)
Now with the touch detection explained, this is how the sequence script checks for the correct color value it is expecting when it is checking for a specific color pad to be touched. The following is the main sequence code:
local players = game:GetService("Players")
local colors = game.Workspace.Colors
local touchValue = game.Workspace.recentTouched.Value
local plrName = ""
local array = {}
local arrayStr = ""
-- Get all colors under folder into an array.
for i, item in pairs(colors:GetChildren()) do
array[i] = item.Name -- Get all color names in array.
arrayStr = arrayStr .. item.Name .. ", "
end
print("Colors Detected: " .. arrayStr)
-- Pick Randomized Color.
local function pickColor()
print("Picking color ...")
local num = math.random(1, 8) --Note to self: Lua arrays start at 1 instead of 0
local picked = array[num]
print("Picked " .. picked)
return picked -- Returns string
end
-- Signaling the color plate to the player.
local function signalColor(color)
local object = colors:FindFirstChild(color)
object.Material = Enum.Material.Neon
wait(.5)
object.Material = Enum.Material.Metal
end
-- Check for when player touches an object.
local function checkTouched(color)
wait(2) -- 2 seconds to stand on plate
if touchValue == color then
print("Correct Color Touched!")
signalColor(color)
return true
end
return false
end
-- Main sequence function.
local function initialize(plr)
print("Player: " .. plr.Name)
local plrPart = game.Workspace:WaitForChild(plr.Name)
print("Player " .. plr.Name .. " Model Found.")
local stack = {}
local gameOver = false
local iteration = 1
print("Beginning new sequence ...")
wait(5)
while gameOver == false do
local clr = pickColor()
stack[iteration] = clr -- Stack on new Color
-- Signal All Colors
for index, item in pairs(stack) do
signalColor(item)
wait(.5)
end
-- Detect Touch of All colors
for index, item in pairs(stack) do
print("Checking touch for " .. item .. " ...")
local touch = checkTouched(item) -- Returns Boolean
if not touch then
print("Player touched incorrect color! Last Touch Value: " .. touchValue .. ".")
gameOver = true
break
end
end
if gameOver == true then
break -- Break loop before giving 1+ score.
end
iteration += 1 -- Adds round finished
end
plr:Kick("Game Over! You got a HighScore of: " .. iteration)
end
-- When player joins, begin sequence.
players.PlayerAdded:connect(function(plr)
initialize(plr) -- Pass player added
end)
When it runs its sequence, it will loop through its colors to signal them to the player and then it will loop through the stack again but instead will call the checkTouched() function that will have the color string passed and will return a boolean. This function checks for the string value of recentTouched and compares it to its passed string color value. (Note: recentTouched is a String Value object)
Here is what the problem is. Though the touchDetect script prints out the value of recentTouched when it assigns it to its color as its touched, when checkTouched() checks that same value again, it returns no value though it was assigned before.
Here is the output the game gives when it is ran and a player touches the color pads:
Why is recentTouched returning an empty value when it is retrieved in the sequence script, yet in the touchDetect script it prints out its assigned value and shows that it was properly assigned? Why is this value lost? Sorry this strategy for checking a touched plate may not be the smartest solution
Thank you in advance for the help 

