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 5 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.

local player = game.Players.LocalPlayer
local x = 5


game.ReplicatedStorage.SeeThrough.OnClientEvent:Connect(function(seat)
print(seat.name)
    if seat.Occupant ~= nil then
        seat.Parent.Parts.Part1.Transparency = 0.5
        seat.Parent.Parts.Part2.Transparency = 0.5
        seat.Parent.Parts.Part3.Transparency = 0.5
        seat.Parent.Parts.Part4.Transparency = 0.5
            else
        seat.Parent.Parts.Part1.Transparency = 0
        seat.Parent.Parts.Part2.Transparency = 0
        seat.Parent.Parts.Part3.Transparency = 0
        seat.Parent.Parts.Part4.Transparency = 0
    end
end)

1 answer

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

do you mean something like this?

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

Answer this question