how do i make a button door where theres 1 button on both sides and if u click the first button it opens and if u click the second one it does the exact opposite(close)

if you open it the parts reflectance goes to .1 if you close it the parts reflectance goes to 0

script ;-;

--works VV
local TweenService = game:GetService("TweenService")
local door1 = script.Parent.drag
local tweeningInformation = TweenInfo.new(
    6,   
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    0,
    false,
    0
)
local door1Open = {CFrame = CFrame.new(-122.858, -15.331, 4.78)}
local door1Close = {CFrame = CFrame.new(-122.63, 4.847, -75.692)}
local tween1open = TweenService:Create(door1,tweeningInformation,door1Open)
local tween1close = TweenService:Create(door1,tweeningInformation,door1Close)

local hi = false
local part = script.Parent.Lever1
function hit ()
if part.Reflectance == 0 then
	if hi == false then
		hi=true
	part.Reflectance = .1
tween1open:Play()
	wait(10.5)
	hi = false
	end
	else
	if hi == false then
	hi = true
		part.Reflectance = 0
				print ("carry")
tween1close:play()
			wait(10.5)
			hi = false
end
end
end

script.Parent.Lever1.ClickDetector.MouseClick:Connect(hit)
--first button doesnt work VV
local hi = false
local part = script.Parent.Lever1

if part.Reflectance == .1 then
if script.Parent.Lever1.ClickDetector.MouseClick then
	if hi == false then
		hi=true
			print ("forward")
script.Parent.upgreen.Transparency = 0
script.Parent.upred.Transparency = 1
wait(6)
script.Parent.upgreen.Transparency = 1
script.Parent.upred.Transparency = 0
	wait(4.5)
	hi = false
		else
	if script.Parent.Lever1.ClickDetector.MouseClick then
		if hi == false then
	hi = true
		part.Reflectance = 0
		print ("back")
script.Parent.downgreen.Transparency = 0
script.Parent.downred.Transparency = 1
wait(6)
script.Parent.downgreen.Transparency = 1
script.Parent.downred.Transparency = 0
			wait(4.5)
			hi = false
			end
			end
			end
			end
			end
--second button doesnt
			local hi = false
local part = script.Parent.reflect
if part.Reflectance == 0 then
function hit ()
	if hi == false then
		hi=true
	part.Reflectance = .1
			print ("forward")
script.Parent.upgreen.Transparency = 0
script.Parent.upred.Transparency = 1
wait(6)
script.Parent.upgreen.Transparency = 1
script.Parent.upred.Transparency = 0
	wait(4.5)
	hi = false
	end
	else
		if script.Parent.Lever1.Reflectance == 0 then			
		if hi == false then
	hi = true
		part.Reflectance = 0
		print ("back")
script.Parent.downgreen.Transparency = 0
script.Parent.downred.Transparency = 1
wait(6)
script.Parent.downgreen.Transparency = 1
script.Parent.downred.Transparency = 0
			wait(4.5)
			hi = false
end
end
end
script.Parent.Lever2.ClickDetector.MouseClick:Connect(hit)

5 comments

0

Just do 2 different button like normal

0

i want it to do the opposite function so if click button number 2 it opens and if u click button number1 then number2 it closes

0

Use if statement

0

how do i use the if statement coz i tried and failed

0

If blah blah then ... end