So what I have currently tried is using Remote Events and then tried using Remote Functions(I perhaps struggled with properly utilizing remote functions for this since I did attempt to make the scripts communicate)
I want to make a script ‘iterate’ through a model getting the light and well from there allowing me to change it for the server as I like once a player has pushed a UI TextButton
Currently it’s just printing “nil” instead of the descendants names.
If you’re just changing a light can’t you put it somewhere more plausible? If you want to turn it on for the server use a RemoteEvent, if you want to turn it on for the just the player, use the local script.
I’m trying to turn on a group of lights for the server but it’s not working, not just one light. It prints “nil” regardless of what event I use.
I used
I can replicate the original code(WITH the event) before I attempted another method if it would be helpful.
local descendants = game.Workspace.Cell_Lighting:GetDescendants()
for index, descendant in pairs(descendants) do
print(descendants.Name)
return descendants
end
Ahh, gotcha. So are they all in one model/folder, or are they spread out?
If they are all in one model, fire a RemoteEvent to the server that loops through the model’s children (or wherever the lights are) and proceed to do what you wish, turn them on, etc.
for _, Model in pairs(game.Workspace.Cell_Lighting:GetChildren()) do
There’s your typo. You’re indexing Name from descendants, with the S. This is referring to your table of descendants rather than the object itself. You’re seeing nil because it doesn’t have an index called Name. Only objects indexed by numbers.
Edit: Oops. I didn’t realize the other response was saying essentially the same thing.