Trying to return a Value from a function

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to use another Value in a function

  2. What is the issue? Include screenshots / videos if possible!

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I can’t seem to find a similar problem

I really don’t know how to explain my problem, but it’s exactly like this function.

local function a(name)
      local billboardgui

      local part = Instance.new("Part")
      part.Name = name
      part.Parent = workspace

     if workspace:FindFirstChild(name) then
           billboardgui = Instance.new("BillboardGui")
           return billboardgui
     end
      
end


My problem is basically like this function, I want to return a value but at the same time i want to also change the name of the Part as well in the same Function, but how? I really don’t have any idea on how to change the name of the Part and get the Returned value as well.

Is this even possible? if it is can someone tell me how? if not then can someone tell me it’s not possible?

Thank you very much for responding

(also the Function I displayed right there is just an example of me trying to Explain things.)

Lua Functions can also return what’s called a ‘tuple’, which just means more than one.

For example:

local function getNameAndAge()
    return "Jones", 29
end

print(getNameAndAge())

--//To store in variables:
local name, age = getNameAndAge()

Thank you sooo muuchhh for responding, i’ll try this out

1 Like