Upon attempting to figure out why my script is not working, I find that my StringValue is not changing.

script.Parent.Username.Value = script.Parent.SearchBox.Text -- not changing here,

The full script: Error - Line 10

script.Parent.SearchBox.SearchButton.MouseButton1Click:Connect(function()
	-- Create variables
	local ReplicatedStorage = game:GetService("ReplicatedStorage")
	local Players = game:GetService("Players")
	
	local GroupId = ReplicatedStorage.Settings.GroupId
	local MRank = ReplicatedStorage.Settings.MinimumRank
	local MinimumAge = ReplicatedStorage.Settings.MinimumAge
	
	script.Parent.Username.Value = script.Parent.SearchBox.Text -- < here
	-- Set text
	
	script.Parent.username.Text = "Name: ".. script.Parent.Username.Value
	script.Parent.age.Text = script.Parent.age.Text.. Players:FindFirstChild(script.Parent.SearchBox.Text).AccountAge
	
	-- Set visible buttons
	
	script.Parent.TextButton.Visible = true
	script.Parent.TextButton1.Visible = true
	script.Parent.TextButton2.Visible = true

	-- Find player Age
		
	if Players:FindFirstChild(script.Parent.Username.Value).AccountAge <= MinimumAge.Value then
		script.Parent.age.Text = script.Parent.age.Text.." - User is underage."
	end
	
	-- Find backpack
	
	if Players:FindFirstChild(script.Parent.Username.Value).Backpack:FindFirstChildWhichIsA("Tool")==nil then
		script.Parent.items.Text = script.Parent.Username.Value.." has no items in his backpack."
		script.Parent.TextButton.Visible = true
	else
	for i, v in pairs(Players:FindFirstChild(script.Parent.Username.Value).Backpack:GetChildren()) do
		if script.Parent.items.Text:FindFirstChild(Players:FindFirstChild(script.Parent.Username.Value).Backpack:GetChildren()) then
			else
			script.Parent.TextButton1.Visible = true
			script.Parent.items.Text = script.Parent.items.Text .. "\n" .. v.Name
		end
	end
	end
end)

3 comments

1

What is the error message?

0

attempt to index a nil value - Line 12.

0
  • Sorry, line 14. "Players.(playername).PlayerGui.MetalDetectorGui.Frame.Script:14: attempt to index nil value"