Her issue is that i
is returning nil and she does not want it to return nil.
Not working yet sadly, still returns nill, not the value of i.
I would like to return the value of i, not nill as it is happening.
Instead of returning i
, try printing i
to see if i
even has a value.
Also try:
return Opzioni[i]
instead of
return i
try using prints in the function maybe that would figure out some issues?
but the problem i don’t believe is the for cycle. cause it stops whenever i click the button, and if i put a print in the for cycle, it shows the right number.
It Is Returing Nil Because The Vedimo Function Doesnt Return Anything At All!
The Event It Connected Which Is Inside Of It Returns The i But That Is Read By None,
By Default Every Function Returns nil if it returns nothing, Even Nil Simply Means Nothing!
EDIT:
Look Closely At Vedimo The Function, The Return Is Inside Of That Event Function Clause!
Oh ok I am just not used to seeing only 2 numbers in a for loop.
Have you tried putting stuff in the table?
function Vediamo(Opzioni)
local Clicked = false
repeat
for i,v in pairs(Opzioni) do
v.MouseButton1Click:Connect(function()
v.Parent.Visible = false
Clicked = true
print(i)
return Opzioni[i]
end)
end
wait(0.1)
until Clicked
end
The print tells me the right number, but the return doesn’t work?
Would you like the return to return the number, or something else?
I do not know where the options or what the right number is though? Also it is simpler to use 1 instead of 2 loops. Just have the for loopcheck for clicked and if it is clicked then break
.
Guys Please Don’t Be DUMB (No Offence), The Vedimo Function Is Returning Nothing At All, The Line Of Code return i
is inside the v.MouseButton1Clicked:Connect(<>)
Clause, That Return Statement Is Not Inside The Vedimo Function Instead That Is Inside That Event Function!, Thats Why Vedimo Function Dont Have Any Return Statement And Thus Its Returning Nil!
Also Please Mention What You Wanna Achieve, Thanks,
yes, to return the i or whatever to tell me which button got clicked from the array. I’m ok with even the name of the button, but everything gives nill.
Try this:
function Vediamo(Opzioni)
local Clicked = false
local selectedOption = nil
while not Clicked do
for i = 1, #Opzioni do
Opzioni[i].MouseButton1Click:Connect(function()
Opzioni[i].Parent.Visible = false
selectedOption = i
Clicked = true
end)
end
wait(0.1)
end
return selectedOption
end
local Opzioni = {
Convo.Opzioni.la1,
Convo.Opzioni.la2,
Convo.Opzioni.la3
}
local Scelta = Vediamo(Opzioni)
print(Scelta)
Its Impossible To Get Something In Return From Vedimo Function Since IT is not returning at all! Look At The Function Carefully Please!
OOOOOOOOH NAAAH I JUST REALIZED AGHGHAGHAGHGHAGHAHGAHG
thanks.
But it is returning that is why the function stops. If you don’t understand how return works here is the documentation Returning Values from Tables | Documentation - Roblox Creator Hub
I still don’t understand the solution.
Edit: I understand it now. I feel stupid.