Unexplainable issue

So here is another update on my citation system. It doesn’t work as comes up with the error " is not a valid member of players “Players”". Why is this? Someone help?

local agency = "Malta Police Force" 


game.ReplicatedStorage.Citation.AddCitation.OnServerEvent:connect(function(player,recipient,reason,amount)
	wait(.8)
	local Values = game.Players[recipient].ValuesFolder.CitationValues
	Values.CitationTimer.Value = 30*60
	Values.CitationPending.Value = true
	Values.CitationValue.Value = amount
	Values.CitationReason.Value = reason
	local gui = game.ReplicatedStorage.Citation.CitationAlert:Clone()
	gui.Parent = game.Players[recipient].PlayerGui
	gui.Frame.AMOUNT.Text = amount
	gui.Frame.OFFICER.Text = player.Name
	gui.Frame.REASON.Text = reason
end)
local gui = script.Parent.Parent:FindFirstChild("Citation")
gui.CitationGui.department.Text = agency
1 Like

What did you mean by this recipient? Can you please explain a bit more?

1 Like

How are you firing the RemoteEvent? What are you passing to it?

1 Like
local recipient = script.Parent.Parent.playername.Text
local reason = script.Parent.Parent.reason.Text
local amount = script.Parent.Parent.amount.Text

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.Citation.AddCitation:FireServer(recipient,reason,amount)
	script.Parent.Parent.Visible = false
end)

I am passing the reason why the citation was submitted (reason), the person who is going to recieve the citation (recipient), and the amount to be payed.

The person who will have to pay the citation.

Put the receipient, reason, and amount lines in the MouseButton1Click event. Change your localscript to this

local frame = script.Parent.Parent

local recipient = frame.playername
local reason = frame.reason
local amount = frame.amount

script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.Citation.AddCitation:FireServer(recipient.Text,reason.Text,amount.Text)
	frame.Visible = false
end)

That fixed it, but why, if I may ask?

You immediately were retrieving the Text from all of the textboxes, if you had nothing in that textbox, it would return nil into those variables. Reference the text when it needs to be references. Also I recommend adding an if statement before all the code in your RemoteEvent since it’ll error if a player was not found, I recommend after the wait(.8) that you do if not game.Players:FindFirstChild(recipient) then return end to not continue if a player with the name was not found

Also if my post was the solution, it’s best to mark it as the solution so others will know that the post has been solved