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

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

Asked by 3 years ago

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?

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 Spjureeedd 385 — 3y

2 answers

Log in to vote
0
Answered by 3 years ago
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".

Ad
Log in to vote
0
Answered by
xxaxxaz 42
3 years ago
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.

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. Spjureeedd 385 — 3y

Answer this question