Argument 1 missing or nil - Local Script

I’m scripting a local script for a citation system and I want the “person” textbox to find the person’s username in the game.

Error

Argument 1 missing or nil - Client - Client:8 12:42:53.711 Stack Begin - Studio 12:42:53.711 Script 'Players.LMVM2041.PlayerGui.Citation.Main.Client', Line 8 - Studio - Client:8 12:42:53.711 Stack End - Studio

Code

local event = game.ReplicatedStorage.Cite
local players = game:GetService("Players")

script.Parent.Submit.MouseButton1Click:Connect(function(plr)
	local amount = script.Parent.AmountDue.Text
	local suspect = script.Parent.Name.Text

	if players:FindFirstChild(suspect) then
		print("Suspect found!")
		event:FireServer(suspect, amount)
	end
end)

Error line in code

if players:FindFirstChild(suspect) then

Can anybody help?

Could be the name of the text box, as the name you gave it, Name is also the name of a property and properties take priority. Perhaps try changing the name of it? It could also be you forgot to write any text and thus sees suspect as nil.

Also to ensure you don’t do another mistake, MouseButton1Click returns nothing, so get rid of plr

2 Likes