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

Any help with a Search GUI? [Unanswered]

Asked by 8 years ago

I was experimenting with Search GUI's and came up with this, now I was wondering if someone can tell me what I am doing wrong with it as to why it's only working if I type the full text? I want it to be visible if I type stuff like C and there's a frame named Cow.

Here's what I tried:

local frame = script.Parent.Parent.ScrollingFrame

script.Parent.Changed:connect(function()
    for _,v in pairs(frame:GetChildren()) do
        if string.find(script.Parent.Text,v.Name) then
            v.Visible = true
        else
            v.Visible = false
        end
    end
end)

How would I make it work if I typed stuff like "C"?

Any help appreciated.

Sorry I can't explain any better.

1 answer

Log in to vote
0
Answered by 8 years ago

This works if there is everything in one parent:

local text = "c"
text = text:lower() -- to avoid stuff ups
local children = script.Parent.Frame:GetChildren()

function check()
    for _,v in pairs (children) do
        local s = text:len()
        local find = v.Name:sub(1,s)
        find = find:lower()
        if find == text then
            return v
        end
    end
end

check()

SORRY, ANOTHER ERROR I MADE I have fixed it :/ local s = text:len(), not v.Name:len(). It works now. Hope I helped :)

0
calling 'len' on bad self (string expected, got table) 22:34:29.702 - ISellCows 2 — 8y
0
Sorry about that, was a small error. Try it now. TheDeadlyPanther 2460 — 8y
0
Still doesn't work. :/ ISellCows 2 — 8y
0
it works. I tested it myself. Copy this into a scripr inside a screenGui. also inside the screengui should be a frame called Frame with a Frame inside it called Cow TheDeadlyPanther 2460 — 8y
0
It set's it's visible to false, even if I type "C" or "c". :/ ISellCows 2 — 8y
Ad

Answer this question