How do i access a variable from a function to another function?

Title says it all, How do i pass a variable from a function to another function? In my case, an array from a bindable event to a function… How do i make the function access the array from the bindable event?
Thanks in advance!!

1 Like

Actually, i could just use module scripts and put the variable in the module script… And the 1st function can access the variable and also the 2nd function using module scripts!!

1 Like

Also want to add that you can both pass variables from one function to the other, and you can also use a variable in the scope of both functions.

local function func1(arg)
    print(arg) --> cool argument
end

local function func0(arg)
    func1(arg)
end

func0('cool argument')

or

local var = 1

local function func1()
    print(var) --> 1
    wait(5)
    print(var) --> 5
end

local function func0()
    coroutine.wrap(function()
        wait(2)
        var = 5
    end)()
    func1()
end
func0()
1 Like

Thanks so much!! I really appreciate it!!

1 Like