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

This search script isn't working?

Asked by 9 years ago

I've made this yesterday, then I forgot to save my studio and made it again but this time a little better. When I try to search "Wood" or anything else that's searchable, it says "Type here is not a valid member of ScrollingFrame" (Type here is the acutal text of the textbox)

My script:

bar = script.Parent.Parent.SearchBar
text = bar.Text
button = script.Parent
frame = script.Parent.Parent.ScrollingFrame
dirt = frame.Dirt
grass = frame.Grass
sand = frame.Sand
ice = frame.Ice
wood = frame.Wood
stone = frame.Stone
all = frame:GetChildren()
button.MouseButton1Click:connect(function(search)
    stone.Visible = false
    dirt.Visible = false
    grass.Visible = false
    ice.Visible = false
    sand.Visible = false
    wood.Visible = false
    wait(.1)
    frame[text].Visible = true
end)

1 answer

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

Your problem is line 2. This mistake is made very often. When you set a variable to an object's property, the variable simply becomes the value of that property, retaining no reference to the object. This means that the variable will not change if the property changes later.

Make your variables equal to objects, then access the properties like so;

local part = workspace.Part
part.Transparency = 1
0
Thanks! Operation_Meme 890 — 9y
Ad

Answer this question