It is, and you can probably get quicker, but I can’t remember how. What I use is a lot of variables, for no reason… It works for me, and if you do it right, it will also work for you.
--Add a localscript to you Gui
--I wrote this code out without testing it
--So if there is syntax error etc or reference not correct you should change that.
--You will have to loop get the userdata and place it into an table with GetChildren function
--e.g
local laneColorAll = script.Parent.LaneColor:GetChildren() --add reference to the frame
local buttonPressed = nil
for key,value in pairs(laneColorAll) do
--this checks if the userdata is a frame and not that UILIisLayout
if value:IsA("Frame") then
--Make sure all buttons names is Key1 here
value.Key1.MouseButton1Down:Connect(function()
buttonPressed = value --This gets the button you pressed
end)
end
end
--The above code you will have to repeat for each multi buttons those 4
--Now to get the color pressed we can use the same code in a way
--add reference to that color pallette I don't I can't see what it is there in your image
local colorPalleteAll = script.Parent.ColorPallette:GetChildren()
local colorSelected = nil
for key,value in pairs(colorPalleteAll) do
--this checks if the userdata is a frame and not that UIListLayout
if value:IsA("Frame") then
--Make I am not sure how your color pallete looks but if it is also frames with button inside then
--do the same make sure Key1 here is the name of you color button
value.Key1.MouseButton1Down:Connect(function()
colorSelected = value.BackgroundColor3 --Read more about this api
end)
end
end
Read here about the what TextButton.BackgroundColor3 returns
Thank you for your help but I also have to apologize at the same time that I already finish the unfinished code before you finish it.
I also test your code now It all working fine, Thank you very much for this suggestion
However what I also need is to change the Value from a folder which I never have done before, Here is my code:
local LC = script.Parent:WaitForChild("LaneColor")
local CS = script.Parent:WaitForChild("ColorSet")
-----------------------------------------------
-----------------------------------------------
local Ready = true
local SelectedColor = nil
function RequestColor()
return coroutine.create(function(FrameName)
if Ready == true and SelectedColor == nil then
Ready = false
CS.Visible = true
repeat wait(0.1) until SelectedColor ~= nil
FrameName.BackgroundColor3 = SelectedColor
CS.Visible = false
SelectedColor = nil
Ready = true
end
end)
end
-----------------------------------------------
for w,g in pairs(CS:GetChildren()) do
if g:IsA("TextButton") then
g.MouseButton1Click:Connect(function()
SelectedColor = g.BackgroundColor3
end)
end
end
for i,v in pairs(LC:GetChildren()) do
if v:IsA("Frame") then
for e,a in pairs(v:GetChildren()) do
if a:IsA("TextButton") then
a.MouseButton1Click:Connect(function()
coroutine.resume(RequestColor(),a,v)
end)
end
end
end
end
So yes, It send out a and v data, But v one not getting for use yet because that is for changing the value data that is inside folder, Which is here:
Your are passing the information to coroutine.resume incorrectly
It only needs one argument which is the couroutine.create you returned.
This is how you should passed it
--RequestColor returns coroutine.create() which is correct but
--also want to pass arguments to the RequestColor function asswell
coroutine.resume(RequestColor(v))
--also you should set the parameter in
--like so
function RequestColor(FrameName)
--FrameName now is v
end