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

How can you have a variable at the end when trying to locate something?

for i = 100, 0, -1 do
			if script.Parent.Parent.Name == 'Signal'..i then
				i = i - 1
				game.Workspace.Signal[i].Yellow = 0
				game.Workspace.Signal[i].Green = 0.7
				i = i - 1
				game.Workspace.Signal[i].Yellow = 0.8
				game.Workspace.Signal[i].Green = 0
			end
		end

How do you make it so that you can find something with i as a number? I'm getting this error: 15:26:34.594 - Signal is not a valid member of Workspace

It's the line after the for i = that is having the problem.

1 answer

✓ Accepted answer

I'm going to assume that you're trying to do something with children of the workspace named SignalX, where X is a number. In that case, you should replace:

game.Workspace.Signal[i].Yellow = 0

for example, with this:

game.Workspace["Signal".. i].Yellow = 0

This means that it will add the value of i to the end of "Signal", then get the object with that name.

Apologies if I've got the context of the problem incorrect.

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