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

How would i test/debug for errors on roblox scripts? any help appreciated

Asked by 4 years ago

people always tell me that i should but i'm a begginer. would i print something on the line after the suspicous line of code? any help appreciated

4 answers

Log in to vote
1
Answered by
ryan32t 306 Moderation Voter
4 years ago
Edited 4 years ago

You can use Print() to debug.

Example Of Debugging With Print:

local part = workspace.Part -- Defining "part"

if part then -- if part exists then
    print("part exists") -- print "part exists"
end

By working the logic in your brain that, "part exists" will only be printed if part does exist, then you can conclude that the part does not exist, only if "part exists" does not print. But, if "part exists" does print, then part does exist.

Ad
Log in to vote
0
Answered by
Lakodex 711 Moderation Voter
4 years ago
Edited 4 years ago

Quick Simple tutorial

--Lets say we are doing something here we don't know if it is working or has any signs [Of course this will not work. It is just an example]

local l = v --Since v is undefined. It will return an error in console
print("Working") --Seeing "Working" In console means that the code above worked.
Log in to vote
0
Answered by 4 years ago

So first it matters on your error.

If you mistyped something, it will get you an error in the output and you can just correct it. Thats the easiest error.

But if you didn't mistype anthing, you have no error in your output and your script isn't working, then you can use printing or if-statements.

As beginner, you don't really need to be good at debugging stuff, just ask others or here, in ScriptingHelpers and people will most likely answer your question.

Log in to vote
-1
Answered by 4 years ago

Try to make if-then statements either before or after the suspicious line of code, and within your function print something if it returns true, and if it doesn't print you can continue to debug your line of code.

Answer this question