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

PlayerRemoving not being called when player leaves, why?[SOLVED]

I have a script in the "ServerScriptService" folder and in the script i have:

function playerLeft(player)
	print("numPlayers: ",#Players["players"])
	for i = 0,#Players["players"] do 
		print("Player: "..Players["players"][i]," is the same as: "..player.Name,": ",Players["players"][i] == player.Name)
		if Players["players"][i] == player.Name then 
			table.remove(Players["players"],i)
		end 
	end 
	local encodeData = http:JSONEncode(Players)
	local anythingReturned = http:PostAsync(url,encodeData)
	local decodedDataReturned = http:JSONDecode(anythingReturned)
end
game.Players.PlayerRemoving:connect(playerLeft)

But it doesn't get called, why? I have no idea how to fix this, no error comes up. I've also looked at Roblox Wiki and it seems like i'm using it properly.

1 answer

I was having a brainfart moment. I realised i had an infinite loop above the function which would have never added the event listener which in return would not have called the playerLeft function when a player leaves the game.

1 comment

1

nice

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