I'm not sure why this is happening.

Basically, I'm trying to send a table through a remote event which tells the client what players are in the game. From this, I want to fill up a text box full of the names of the players.

playersRemote = game.ReplicatedStorage.playersExchange


playersRemote.OnClientEvent:connect(function(arg)
	
	players = arg
	for i=1,#players do
		if players[i].Name == game.Players.LocalPlayer then
			table.remove(players,i)
		end
	end
	--Using the above code to take out the local player from the table
	
	for i=1, #players do
		
			script.Parent:FindFirstChild("plr"..i.."name").Text = players[i].Name
			--This is where it says I'm trying to index a nil value
	end
	script.Parent.Visible = true
end)

11 comments

0

oh my deprecated cde

0

Thank you for pointing that out, but that doesn't help anyone. What part of my code is deprecated? I'm just trying to learn remote events and filtering enabled gameplay since I left roblox about a year ago.

0

connect is deprecated in favor of Connect & you should be using local variables

0

if players[i].Name == game.Players.LocalPlayer --> game.Players.LocalPlayer.Name, as for the nil part..you have a bunch of children of script.Parent named "plr1name", "plr2name", etc? Because that is what your script is currently doing but it doesn't quite match up with the question description

0

Thank you, and yes that's how my gui is laid out.

0

Okay, is the nil value players[i].Name or the FindFirstChild line?

0

It's on the find first child line

0

There are equal amounts of "plrname" as there are players? Maybe it will help if you look yourself in explorer to make sure they all exist

0

There can never be more than 4 players in my game, and because 1 of the players is the local player (and wont need to see themselves in the list), I've only put 3, so they are all there.

0

Or possibly you would require a WaitForChild in the event that they are being created while the loop is running

0

The error means either "script.Parent:FindFirstChild("plr"..i.."name")" doesn't exist or "players[i]" doesn't exist. Find out which one. I'm guessing the former.