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

How to find something in workspace without having to use capitalization?

So if there is a part called "DoorTrigger" in workspace and i want to find it by just typing "doortrigger" how would i do that?

1 comment

0

One way, which is the first way I think of, is to get all parts that is in Workspace. Then checking each one to the string you typed but lowered. Check string.lower() https://developer.roblox.com/en-us/api-reference/lua-docs/string

2 answers

✓ Accepted answer
local function findPart(fromParts, searchWord)
	for i, part in pairs(fromParts) do
		if part.Name:lower() == searchWord:lower() then
			return part
		end
	end
end

print(findPart(workspace:GetChildren(), "doortrigger"))

Now this is an example code that I just put together, but it should do the work of showing you how you can think. To explain what part.Name:lower() does it takes the string, which is the name of the Part, and makes all letters lowercase. "DoorTrigger":lower() = "doortrigger".

local game.Workspace.DoorTrigger = DoorTrigger

or if you do not want to do a varibile

game.Workspace.DoorTrigger

or

workspace.DoorTrigger

when you do game before workspace then workspace has a capitalized W so Workspace and when you do no game before it you do workspace all lowercase.

1 comment

0

One, you didn't really read and understand the askers question, but it was nice of you to try to give an answer. And two, have you been away from coding? Because you've actually flipped the way you make a variable. The name of the variable first, then the value of it.

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