I'm trying to adapt a gate script from one I've got from free models, the current script works by having the player click a lever which then makes the lever handle change direction and the gate open. However I want to change it so that the gate opens by a button and not by a lever.
Here is the script for the lever, I'm not sure what part to remove to just have it open by a simple button click, is it possible somebody could explain all the parts of this script for me?
local divs = 32 local time = 0.5 local dist = math.pi / 2
local progress = 0 local direction = 1
function positionLever(angle) local base = script.Parent.LeverBase.CFrame local transform = CFrame.fromEulerAnglesXYZ(angle, 0, 0) * CFrame.new(0, 1, 0)
script.Parent.Lever.CFrame = (base * CFrame.new(0, 0.5, 0)) * transform
end
local ang = math.pi / 4 positionLever(ang) script.Parent.Lever.ClickDetector.MouseClick:connect(function() if progress ~= 0 then return end
direction = -direction
while true do
if progress >= divs then
script.Parent.UpDown.Value = not script.Parent.UpDown.Value
progress = 0
break
end
progress = progress + 1
ang = ang + ((dist / divs) * direction)
positionLever(ang)
wait(time / divs)
end
end)
All I need the script to do is that when a button is click it activates a parent script:
script.Parent.Lever.UpDown.Changed:connect(function() script.Parent.PortcullisGate.Open.Value = true end)
Which I believe then activates another script which causes the model PortcullisGate to open.
