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

Help me with this table script?

What it should if someone has any BLtoos it will change the text saying yes.

At the moment it is changing the text from blank to No even if they have any of those tools.

BLTools = {
"Move",
"Clone",
"Delete",
"F3X",
"Stamper 2.0",
"DeleteTool",
"Clone Tool",
"RoateTool",
"RecentParts",
"ConfigTool",
"WiringTool",
"ClassicTool",
"OwnerCameraTool",
"Building Tools",
}
script.Parent.Parent:WaitForChild("Safe")
for i,v in pairs(BLTools)do
	if v:lower() == script.Parent.Text then
		script.Parent.Parent.Safe.Text = "Yes"
	else
		script.Parent.Parent.Safe.Text = "No"
	end
end

2 comments

0

What is script.Parent.Text? That is most likely your problem.

2 answers

✓ Accepted answer

TurboFusion's answer is correct; if you really want case-insensitivity, you should use :lower() on both strings:

if v:lower() == script.Parent.Text:lower() then

There is another problem.

For each of the strings in BLTools, you set the text of Safe.

That means whatever value is reached last will be the sole decider of Safe's text.


What you probably want is if any of them match.

In that case, set to No once before the loop, and allow any to set to yes:

Text = "No"
for blah do
	if blah then
		Text = "Yes"
	end
	-- no else!
	-- you don't know what to do with just ONE
	-- failure of the many options!
end

The reason your script isn't working properly is because you're making the name of the tool lowercase, but there is no text in the table that is all lowercase. So to fix this, you have to make both the text in the table lowercase and the name of the tool lowercase and then compare the two, like so:

if string.lower(v) == string.lower(script.Parent.Text) then
	--Do stuff
end

Hope this helped!

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