Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

table expected got nil error?

while true do
	wait()
repeat wait() until workspace.Values.Classic.Value == true 
for i,z in pairs (_G.Playing) do 
	if z.Character.Humanoid then
			z.Character.Humanoid.Died:connect(function() -- identifying if the character dies
				for i,v in pairs (_G.Players) do -----------------------errors right here..
					if v.Name == z.Name then -- making sure that this player died is a member of table
				print(z.Character.Name..' has died')
						table.remove(_G.Playing, i) -- removes from table
						print(i,z)
						break
					end
					end
			end)
	else
		return error('No player found in the table _G.Playing!')
			end
end
end

I basically explained it in the table but this script is SUPPOSE to wait until a character died from the table _G.Playing then removes it so that another script can verify id the table only has 1 player, and yes i inserted the player into the table not the player's name..

1 comment

0

If its nil it means _G.Players doesn't exist. Are you sure you have set it's value within the script's parent?

1 answer

✓ Accepted answer

Unless you have defined _G.Players somewhere else then it does not exist! I presume you are trying to loop through players where the error is. To do this simply use this:

for i,v in pairs(game.Players:getChildren() do
	-- Do stuff here eg. if z.Name == "blah"
end

1 comment

0

Thank you it worked!except i put it in a different place to make it work

This discussion is preserved as it was. New answers, comments, and votes are closed.