ChosenColor value is nil

Alright so I’m making a game similar to color block and the way the round works is that the server will pick a random color from a table and then all other parts that are not that color will go invisible and their cancollide will be false.

I’m using a remote Event to control a gui that will announce the color, however when I print the color on the server script it works fine but when I print the color on the LocalScript it returns my ChosenColor as nil. Anyone know why?

ServerScript:

LocalScript:
image

you dont need an event to make the parts invisible and turn their collisions off. Just change it on the server and the changes will be replicated to all clients

I’m only showing you the part of my script that I need help with. I have already coded what your telling me to do and my entire round system is finished. I’m trying to get the LocalScript to display the ChosenColor on a gui for players to see

oh, my bad.

  1. instead of looping trough all the players just do RE2:FireAllClients(ChosenColor)
  2. Make sure that the event is a “RemoteEvent”
  3. Where is the LocalScript located? (StarterPlayerScripts Or StarterGui should work if you arent already using that)
  4. Make sure that the Client has started “Listening” to the event. This is done when the code has reached the function. if you for example have a “While true” loop before it then the client will never start listening to the event
  5. Make sure the “Print” function is running on the server in the first place

These are all the things i could come up with that might be the problem

I’m just realizing now that the client was connected to a different RemoteEvent.

Thanks for the help I probably would have never checked if I had it connected to the right RemoteEvent!

1 Like

Also just a suggestion, why not use :FireAllClients instead of looping through, defining the same variable and firing client individually, if not that, atleast take the chosen color variable out from the loop.

I actually just learned about it’s function. I was looking at the documentation for remote events and saw that it does that, and another guy in the thread suggested it