Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do i activate or run a function without using events?

Asked by
CjayPlyz 643 Moderation Voter
5 years ago
Edited 5 years ago

How do i activate a function without using events?

For example i have this.

local function A()
    --random codes
end)

local function B()
    --random codes
end)

Now, How do i make it so that when the function "A" activates, It will activate function "B".

local function A()
    --random codes

    --a code that runs or activate function B
end)

local function B()
    --random codes
end)

But, I don't wanna use something like this.

Script.Parent.Touched:Connect(B)
Script.Parent.Changed:Connect(B)

P.S if it's not possible or i'm just bad at explaining please don't dislike just tell me in the comment.

1 answer

Log in to vote
1
Answered by
amanda 1059 Moderation Voter
5 years ago

To call a function, you can simply say the functions name, followed by a set of parentheses.

Here is how you would fulfill your request:

local function B()
    print("B")
end)

local function A()
    print("A")
    B() --call function B
end)

A() -- call function A
0
Thanks amanda :) CjayPlyz 643 — 5y
0
Sure, let me know if you have more questions. amanda 1059 — 5y
Ad

Answer this question