Remote event parameter is returning a value as nil?

So for my remote event called “CharacterClicked”, I put the script that fires the remote event in a local script. When it fires, the custom parameter I put is a StringValue. The StringValue is called “CharacterChosen”

characterClicked and characterChosen is defined as a variable.

characterClicked:FireServer(characterChosen.Value)

Then for the event listener in a server script, I put this:

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

The player value prints out as my username “Richperson03return”
The characterChosen value prints out as “nil”

It StringValue isn’t equivalent to nil. Can someone please tell me how remote event parameters work and how can I fix this?

This means that you haven’t set a value for the StringValue object. Can you show me the script where you edit the value or the properties of the StringValue?

image
It is inside of a for loop so v is equal to an Image Button

This script works, because when I test the game and go to the StringValue I can see it changing. It’s just the event listener that returns it as nil.

It might be because you were changing the characterChosen.Value from the client side. Try use a variable inside the client to replace characterChosen.Value

If that didn’t work then maybe the string value wasn’t assigned anything on the server because if it was an emptz string, it would print “” instead of “nil”

I tried what you said, and it worked, so thank you!

I still don’t fully understand why it didn’t work though. But I see what I have to do now.

1 Like