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

Why am I still getting errors from a pcall() statement?

I've attempted to search around for a solution, but I guess no one has tried something like this yet? Anyhow, here's the problem:

All I want to do is see if instances[i] has a parameter for text. Then add the text to a table.

if pcall(instances[i].Text) then
	table.insert(text, #text + 1,instances[i].Text)
end

(Section of the full script)

I still get an error:

Text is not a valid member of ScreenGui

and the script stops.

3 comments

0

Are you sure you're using pcall correctly?

0

@JesseSong I believe so, but I've never really used it before. So I could be wrong.

0

Also, it seems that theres nothing in the workspace called Text make sure there is And add a waitforchild.

3 answers

don't you need to do pcall(function)?

1 comment

0

thats correct, you have to pcall functions

table.insert(text, #text + 1,instances[i].Text)

That is not enclosed in pcall. Also you need pcall(function() instances[i].Text end).

Your pcall function is incorrect make sure you have a function as near it. This is the only error I can see in your code..

if pcall(function() instances[i].Text then
    table.insert(text, #text + 1,instances[i].Text)
end
end)

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