How to have 1 script reference some models and another to reference all

Hello, I have some pillars and I wish to control them from a button where it will raise and drop 3 from the front and 3 from the back (there is also 4 from the front and 4 from the back) and I wish to also have an emergency button where all of them gets raised or dropped.

Some screen shots : Screenshot - e1ae7eb4c43db4f6b1f2fbe6748953d4 - Gyazo

Script :

local RunService = game:GetService(“RunService”)
local TweenService = game:GetService(“TweenService”)

local Pillar = script.Parent
local ProximityPrompt = Pillar.Top.ProximityAttachment.ProximityPrompt

local DefaultTweenInfo = TweenInfo.new(5)

local RaisedPosition = Pillar:GetPivot()
local DownPosition = RaisedPosition * CFrame.new(0, -Pillar.Union.Size.Y - 0.1, 0)

local isDown = false
local isActive = false

local function tweenModel(model, tweenInfo, targetCFrame)
local steppedConnection

local CFrameValue = Instance.new("CFrameValue")
CFrameValue.Value = model:GetPivot()

steppedConnection = RunService.Stepped:Connect(function ()
	model:PivotTo(CFrameValue.Value)
end)

local tween = TweenService:Create(CFrameValue, tweenInfo, {Value = targetCFrame})
tween.Completed:Connect(function ()
	steppedConnection:Disconnect()
	CFrameValue:Destroy()
	task.defer(tween.Destroy, tween)
end)
tween:Play()

return tween

end

ProximityPrompt.Triggered:Connect(function (player)
if isActive then return end

isActive = true
isDown = not isDown

ProximityPrompt.ActionText = isDown and "Raise" or "Lower"

local tween = tweenModel(Pillar, DefaultTweenInfo, isDown and DownPosition or RaisedPosition)
tween.Completed:Connect(function ()
	isActive = false
end)

end)

Something like this but instead have the pillars.

Baseplate.rbxl (47.8 KB)

Instead of one script per pillar, you could have one script for the entire road checkpoint thing. It controls all the proximity prompts and all the pillars.

you could use Folder as a group for all pillars. And then getting the table which contains All the pillars using pairs(game.Workspace.FolderName:GetChildren()

So I did the script but when I insert it in my map it won’t work any ideas?

This is the script:

Untitled-Game.rbxl (49.2 KB)

use a for loop then assign a function to each pillar