I'm making a search system in my game where you search something (in this case a desk) and you get whatever is inside the desk. Here's the code:
get = game.Workspace.Get
searchtime = script.Parent.SearchTime.Value
contents = script.Parent.Contents.Value
target = workspace:FindFirstChild(script.Parent.Contents.Value)
get.Changed:connect(function()
if get.Value == "Player" then
script.Parent.Contents.Value = "Matches"
script.Parent.What.Value = "Searching Desk..."
script.Parent.TextLabel.Text = script.Parent.What.Value
script.Parent.TextLabel.Visible = true
wait(searchtime)
script.Parent.TextLabel.Visible = false
target.Value = target.Value + 5
end
end)
"Get" is just a trigger value that when changed, this script fires. So basically, it sets the contents to "Matches", waits the searchtime value, then sets "target" to the contents value. Target is what i believe to be the problem. Using FindFirstChild, i have it find the contents value inside workspace. In this case, its matches. There is a "Matches" Value inside workspace which is the value holding the total matches the player has. The target finds the "Matches" value, then changes the value. This is where Output is telling me I have done something wrong. Output says: "Attempt to index global "target" (a nil value).
All help is greatly appreciated.

1 comment
Yep, it worked! Thank you!