Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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!

3 comments

0

If you dont parent it, then you cant use waitforchild on it...

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

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.

1 answer

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, LogService returns 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.

This discussion is preserved as it was. New answers, comments, and votes are closed.