Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way to change properties of multiple objects with Arrays?

Asked by 6 years ago

Hey all, I'm tired of changing a property of multiple objects one by one, but when I tried to make an array to solve this it did not work. How could I have this so all of these could be changed with a table, I do not know where to begin.

01local player = game.Players.LocalPlayer
02local x = 5
03 
04 
05game.ReplicatedStorage.SeeThrough.OnClientEvent:Connect(function(seat)
06print(seat.name)
07    if seat.Occupant ~= nil then
08        seat.Parent.Parts.Part1.Transparency = 0.5
09        seat.Parent.Parts.Part2.Transparency = 0.5
10        seat.Parent.Parts.Part3.Transparency = 0.5
11        seat.Parent.Parts.Part4.Transparency = 0.5
12            else
13        seat.Parent.Parts.Part1.Transparency = 0
14        seat.Parent.Parts.Part2.Transparency = 0
15        seat.Parent.Parts.Part3.Transparency = 0
16        seat.Parent.Parts.Part4.Transparency = 0
17    end
18end)

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

do you mean something like this?

1Array = {Object1,Object2,Object3,Object4}
2for i = 1, #Array do
3    Array[i].Transparency = 0
4end
Ad

Answer this question