Why isn't :GetPlayerFromCharacter working?

Hi,

I have this function that adds +1 win to the player, but it doesnt appear to work… Is there anything wrong here? It runs once it there is 1 player left in the table.

local function getWinnerName()
	if activePlayers[1] then
		local player = Players:GetPlayerFromCharacter(activePlayers[1])
		if player then
			local leaderstat = player.leaderstats
			local wins = leaderstat:FindFirstChild('Wins')
			wins.Value += 1
		else
			print('player not found')
		end
		
		return activePlayers[1].Name
	else
		return 'Player Disconnected'
	end
end
1 Like

You shouldnt be using GetPlayerFromCharacters since activePlayers[1] IS the player.

2 Likes

I assume that you already access the Player from your table, hence, you dont really need to use GetPlayerFromCharacer().

You mainly will use GetPlayerFromCharacer() when you’re working with the character itself and you want to get the player whom represented by that character.

2 Likes

thanks for the replies, I realized this as soon as I asked this question :rofl:

2 Likes