Attempt To index nil with name?

i am tryna make mute command and i keep getting this error

script.Parent.MouseButton1Click:Connect(function()
		local plr = game.Players:FindFirstChild(script.Parent.Parent.PlayerName.Text)
		
		local MuteModule = require(game.Workspace.Infinite.Main.Commands.Moderating.Mute)
		
		MuteModule.Execute("coolman21627", plr)
end)

button script

local module = {
	CommandName = "Mute",
	Description = "stops a player from talking.",
	CanUseOn = "Player"
}

function module.Execute(AdminName, Player)
	local ChatService = require(
		game:GetService("ServerScriptService")
		:WaitForChild("ChatServiceRunner")
		:WaitForChild("ChatService")
	)

	local Channel = ChatService:GetChannel("All")
	for _, speakerName in ipairs(Channel:GetSpeakerList()) do
		Channel:MuteSpeaker(Player)
	end
end

return module

module

Can you send a screenshot of the error. And at which script of this is it failing?

this is the
error:
Workspace.Infinite.Main.Commands.Moderating.Mute:16: attempt to index nil with ‘Name’ - Server - Mute:16

but if i make either script have name it gives me the error

here script
Capture15151515

Playername.Text isnt a valid member of player, instead it’s simply just player.Name

thats the textbox name though i so idk

Oh, text box name, show me where the local script is located.

its a server script because of require cos idk if local works with require

Capture1515151515151

Module is in workspace aswell idk if that breaks it

That isn’t the way to get the player, if the text is the player’s username it won’t get the player, use game.Players.LocalPlayer instead.

server script that wont work… idk

Then use player added and get the plr parameter.

its an admin panel it isnt supposed to affect the player who is an admin

game.Players.PlayerAdded:Connect(function(plr)
if plr.Name == "coolman21627" then
		local MuteModule = require(game.Workspace.Infinite.Main.Commands.Moderating.Mute)
MuteModule.Execute("coolman21627", plr)
end
end)

Just a simple if statement and you’re good to go!

ill just redo it but idk why it wont work

Don’t put the module script in workspace, put it in serverscriptservice! It’s quite unsafe in workspace and exploiters can easily exploit with that.

That’s not true, it doesn’t really make a difference.

As far as the rest of this thread goes, it’s because Player is nil. Possibly @coolman21627 didn’t type the full player name with the correct capitalization.