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

[SOLVED] Is it possible to get the line of a code that called a specific function?

Asked by 1 year ago
Edited 1 year ago

For example, when I try to find an Instance that isn't parented in to a specific Parent using :WaitForChild(), it warns "Infinite yield possible on 'line of code here'". How can I get the line of code like in the example? Is it really possible? Thanks!

0
If you dont parent it, then you cant use waitforchild on it... Kingu_Criminal 205 — 1y
0
@KinguCriminal i know im just showing an example. what im asking i that i it possible to get the line of code that called the function T3_MasterGamer 2189 — 1y
0
T3_MasterGamer, you can't 'get' a line of code. If you are trying to find out when a function creates something. or whatnot... Just user bindableevents, or event listeners. Kingu_Criminal 205 — 1y

1 answer

Log in to vote
0
Answered by
SuperPuiu 497 Moderation Voter
1 year ago

Hello!

I might be late, but you can use LogService for that.

So, here's an example I made real quick:

local LogService = game:GetService("LogService")

LogService.MessageOut:Connect(function(msg)
    local number = string.gsub(msg, "%D", "")

    if not tonumber(number) then return end

    print("Error on line: "..number)
end)

As you can see, LogServicereturns a string that I will save as msg. Now, I use tonumber() to check if the string we just modified is a number and then print the output. Well, this might not be what you want, but that's the best example I could make.

Also it might print as well stuff that was outputed by print(). I didn't done much research, but for you to know, it is possible.

Ad

Answer this question