Hi developers,
I have made a system that will allow the player to control their room with the simple click of a button on a GUI. However, I have an issue where you need to click twice for the script to register part of the code, here is the script,
local Door = script.Parent.Value.Value.Door.Door.Main.ProximityPrompt
locked = false
blinds = false
local DoorStat = Door.Value
local blindsmotor = script.Parent.Value.Value.Blinds.A.Motor
script.Parent.Gradient.Privacy.MouseButton1Click:Connect(function()
if DoorStat.Value == false then -- If door is closed
if locked == false then -- if door is locked
if blinds == false then -- if blinds are down
Door.Enabled = false -- Disables Door
locked = true -- Sets locked to true
blinds = true -- sets blinds to true
for i=1,100 do
blindsmotor.C1 = blindsmotor.C1 + Vector3.new(0,-0.135,0) -- Pulls blinds up
wait(0.0001)
end -- end of putting the blinds up
script.Parent.Gradient.EPB.Text = "Disable Privacy Blinds" -- sets text of button to disable privacy blinds
else -- if blinds are up
for i=1,100 do
blindsmotor.C1 = blindsmotor.C1 + Vector3.new(0,0.135,0) -- Pulls blinds down
wait(0.0001)
end -- end of putting the blinds down
Door.Enabled = true -- Enables Door
locked = false -- Sets locked to false
blinds = false -- Sets blinds to false
script.Parent.Gradient.EPB.Text = "Enable Privacy Blinds"
end
end
else
script.Parent.Gradient.Warning:TweenSize(UDim2.new(1,0,0.193,0))
wait(7)
script.Parent.Gradient.Warning:TweenSize(UDim2.new(0,0,0,0))
end
end)
Here is the line when you disables the blinds, that just gets skipped;
for i=1,100 do
blindsmotor.C1 = blindsmotor.C1 + Vector3.new(0,0.135,0) -- Pulls blinds down
wait(0.0001)
end -- end of putting the blinds down
It makes no sense why it doesnt work with the first click as everything after that does.