Blank value error problem

Hey guys! How are you doing? I hope you do very very well!

Being direct, I made a system where you vote for a single player, but I got a problem, and If a player is dead (a phantom ) then the console chooses another player randomly. But It doesn’t work as I expected,
because it returns a blank value

The problem is that “ChosenPlayerName” keeps in blank even after the “for i, v in pairs() loop”

And when I try to save that Name to a StringValue in the ReplicatedStorage It gives me a blank value because ChosenPlayerName’s Value is nothing, and If I try changing “ChosenPlayerName” to “ChooseAnotherPlayer” then It will give me an error because “ChooseAnotherPlayer” is an instance and not a String Value.

I will appreciate a lot but A LOT of your help and yourself If you can give me a hand with this, even if it’s the smallest one, try giving the smallest Information that may fix this, if you have some question, don’t mind writing it on the comments, thanks for everything and have a nice day! byee! :wave: :grinning_face_with_smiling_eyes: :smiley: :wink:

I’m not sure, but I think that you might not need a for loop here. You might just change it to

local ChosenPlayerName = ChooseAnotherPlayer.Name

However if this won’t work, here’s a second thing that might work:

In the part which chooses another player,
you are getting a random player. And then you’re checking if v.Name is equal to a player. Try changing the choosing part into this:

ChooseAnotherPlayer = game.Players:GetPlayers()[math.random(1, #game.Players:GetPlayers())].Name

I hope that it works!

1 Like

Thanks a lot for your help, It was directly what you said but it lead me to the answer, really really thank you! and have a nice day! :wave: :grinning_face_with_smiling_eyes:

1 Like

I’m glad I could help, and have a nice day too!

1 Like