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?