Remote event parameters aren't working

When you click on a character, it fires the server.

Here is the code in the client that fires the server:

chosenValue = characterChosen.Value
characterClicked:FireServer(chosenValue)

and here is the code in the server:

characterClicked.OnServerEvent:Connect(function(player, characterChosen)

	game.Players[player.Name].Backpack.CharacterChosen.Value = characterChosen

end)

It works perfectly.

But when a player joins a game, it automatically sets the player to an available character.

When a player joins, an AI finds the closest available character to the left. It uses a variable called “available” which is the character it selected. I used “print(available)” to make sure it find the right character, and it works perfectly.

Then it fires the client. The client uses the exact same thing as before but using a new parameter:

chosenValue = available
characterClicked:FireServer(available)

And that also works perfectly. I double checked it using print() again. The available parameter printed out the correct character.

And then it fires the server in the exact same way, and the parameter is the exact same value as it would be if you were to click on the character. But the only issue is it doesn’t work.

In the server I even printed out the parameters. (“available” is “characterChosen”)

print(characterChosen)
print(player)

It printed out the correct character and the correct player.
But the weird thing is that this script didn’t run:

game.Players[player.Name].Backpack.CharacterChosen.Value = characterChosen

All off the parameters are the exact same value as they would be if you were to click on the button. It uses the same system as it would use if you were to click on the button. The only difference is that it doesn’t change the value and keeps it blank. Why?

Is there anything in the output?

No. I used print to see what was happening, and based on what it printed it should be working just fine.

How do you know that the value is kept blank? How did you check it?

The value it’s trying to change is a StringValue in the player’s backpack. It’s suppose to change for the whole server to see. it does it successfully when you click on the character, but not when it automatically sets it.

I just went into the player’s backpack, clicked on the string value, and it was blank. It is blank by default.

weird… do you mind if you send a copy of the script or a portion of it in which it is erroring? Im having a hard time understanding the logic and reproing the error

There were no errors I found after quadruple checking. I’m guessing it could be a roblox glitch, but it could be something technical interfering with it.

I’m guessing it’s a roblox glitch because there is no way it could not work if the parameters are set to the right value. (Checking it using print)

I don’t think there is a way I can fix this, so I’ll probably just end up putting up another script. Thanks for your help anyways.

Update: I figured out what happened. So basically, when the player loads after a second or so the backpack gets replaced by an identical one, clearing out the value in the process. I just put a Wait(3) and it worked!

1 Like