I have a script that should get all the players on the team "Playing" and have a 50% of doing an action, but for some reason my server script cannot find the player in the workspace, when I ask it to print the player, it prints "jediplocoon" which is the name of the only player in the game (me), but when I try and find my name in the workspace it turns up as nil. I would appreciate it if you could point me in the right direction, and hopefully explain why this script doesn't work, so I don't make this mistake again. Here's my script:

local plrs = game.Teams.Playing:GetPlayers()
for i = 1, #plrs do
	print(plrs[i])
	local num = math.random(1, 2)
	if num == 1 then
		local player = game.Workspace:FindFirstChild(plrs[i])
		print(player)
	end
end

4 comments

0

plrs[i].Name as it takes a string

0

yeah just add .Name to the prints

0

thanks! worked like a charm after I added the .Name

0

You can also go through the player itself plrs[i].Character though you should be checking that the player has a character