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)