How am I able to make an until variable?

Since the title doesn’t really make sense I’ll explain:

So, I have a value in a folder called ‘lockdown’ and if it is active, it will do something to the script (you will see below) where it makes one of the lights red and then at that point, I would like it to check until the value == false (the value is called “lockdownvalue”)

Code is below, I have marked the part where I want people to help me edit.

local TS = game:GetService("TweenService")

local proximityPrompt = script.Parent
local proximityPrompt2 = proximityPrompt.Parent.Parent.Parent.Reader2.Prox.ProximityPrompt
local left = proximityPrompt.Parent.Parent.Parent.Parent.LeftDoor
local right = proximityPrompt.Parent.Parent.Parent.Parent.RightDoor

local light1 = proximityPrompt.Parent.Parent.ScannerLight1
local light2 = proximityPrompt.Parent.Parent.ScannerLight2

local lightother1 = proximityPrompt.Parent.Parent.Parent.Light1
local lightother2 = proximityPrompt.Parent.Parent.Parent.Light2

local open = right.DoorOpen
local close = right.DoorClose
local deny = right.KeycardDenied
local access = right.KeycardAccepted
local lockdown = right.DoorLockdown

local lockdownvalue = script.Parent.Parent.Parent.Parent.Parent.Parent.Lockdown

local originalPosition1 = left.CFrame
local originalPosition2 = right.CFrame

local targetPosition1 = proximityPrompt.Parent.Parent.Parent.Parent.LeftDoorTween.CFrame
local targetPosition2 = proximityPrompt.Parent.Parent.Parent.Parent.RightDoorTween.CFrame

local tweenInfo = TweenInfo.new(1.5, Enum.EasingStyle.Linear)
local colorTweenInfo = TweenInfo.new(0.75, Enum.EasingStyle.Linear)

local tween1 = TS:Create(left, tweenInfo, {CFrame = targetPosition1})
local tween2 = TS:Create(right, tweenInfo, {CFrame = targetPosition2})
local tween3 = TS:Create(left, tweenInfo, {CFrame = originalPosition1})
local tween4 = TS:Create(right, tweenInfo, {CFrame = originalPosition2})

local requiredAccessLevel = proximityPrompt.Parent.Parent.Parent.Parent.Access.Value

proximityPrompt.Triggered:Connect(function(player)
	if lockdownvalue == false then
		local playerData = player:FindFirstChild("Data")
		if playerData then
			local playerAccessLevel = playerData:FindFirstChild("Access")
			if playerAccessLevel and playerAccessLevel.Value >= requiredAccessLevel then
				local light1Tween = TS:Create(light1, colorTweenInfo, {Color = Color3.fromRGB(123, 255, 75)})
				local light2Tween = TS:Create(light2, colorTweenInfo, {Color = Color3.fromRGB(123, 255, 75)})
				local lightother1Tween = TS:Create(lightother1, colorTweenInfo, {Color = Color3.fromRGB(123, 255, 75)})
				local lightother2Tween = TS:Create(lightother2, colorTweenInfo, {Color = Color3.fromRGB(123, 255, 75)})

				proximityPrompt.Enabled = false
				proximityPrompt2.Enabled = false
				access:Play()

				light1Tween:Play()
				light2Tween:Play()
				lightother1Tween:Play()
				lightother2Tween:Play()

				task.wait(1.25)
				open:Play()

				tween1:Play()
				tween2:Play()

				task.wait(4)

				local light1Tween2 = TS:Create(light1, colorTweenInfo, {Color = Color3.fromRGB(245, 255, 60)})
				local light2Tween2 = TS:Create(light2, colorTweenInfo, {Color = Color3.fromRGB(245, 255, 60)})
				local lightother1Tween2 = TS:Create(lightother1, colorTweenInfo, {Color = Color3.fromRGB(245, 255, 60)})
				local lightother2Tween2 = TS:Create(lightother2, colorTweenInfo, {Color = Color3.fromRGB(245, 255, 60)})

				light1Tween2:Play()
				light2Tween2:Play()
				lightother1Tween2:Play()
				lightother2Tween2:Play()

				tween3:Play()
				tween4:Play()

				close:Play()
				task.wait(1.5)

				local light1Tween3 = TS:Create(light1, colorTweenInfo, {Color = Color3.fromRGB(254, 254, 254)})
				local light2Tween3 = TS:Create(light2, colorTweenInfo, {Color = Color3.fromRGB(254, 254, 254)})
				local lightother1Tween3 = TS:Create(lightother1, colorTweenInfo, {Color = Color3.fromRGB(254, 254, 254)})
				local lightother2Tween3 = TS:Create(lightother2, colorTweenInfo, {Color = Color3.fromRGB(254, 254, 254)})

				light1Tween3:Play()
				light2Tween3:Play()
				lightother1Tween3:Play()
				lightother2Tween3:Play()

				task.wait(1)

				proximityPrompt.Enabled = true
				proximityPrompt2.Enabled = true
			else
				deny:Play()
				proximityPrompt.Enabled = false
				proximityPrompt2.Enabled = false
				light1.Color = Color3.fromRGB(254, 56, 59)
				light2.Color = Color3.fromRGB(254, 56, 59)
				task.wait(0.1)
				light1.Color = Color3.fromRGB(254, 254, 254)
				light2.Color = Color3.fromRGB(254, 254, 254)
				task.wait(0.1)
				light1.Color = Color3.fromRGB(254, 56, 59)
				light2.Color = Color3.fromRGB(254, 56, 59)
				task.wait(0.1)
				light1.Color = Color3.fromRGB(254, 254, 254)
				light2.Color = Color3.fromRGB(254, 254, 254)
				task.wait(0.1)
				light1.Color = Color3.fromRGB(254, 56, 59)
				light2.Color = Color3.fromRGB(254, 56, 59)
				task.wait(0.1)
				light1.Color = Color3.fromRGB(254, 254, 254)
				light2.Color = Color3.fromRGB(254, 254, 254)
				task.wait(2)
				proximityPrompt.Enabled = true
				proximityPrompt2.Enabled = true
			end
		else
			player:Kick("Data failed to load, please rejoin")
		end
	else -- this is the part I was talking about
		local lightother1Tween4 = TS:Create(lightother1, colorTweenInfo, {Color = Color3.fromRGB(254, 56, 59)})
		local lightother2Tween4 = TS:Create(lightother2, colorTweenInfo, {Color = Color3.fromRGB(254, 56, 59)})
		lightother1Tween4:Play()
		lightother2Tween4:Play()
		lockdown:Play()
		proximityPrompt.Enabled = false
		proximityPrompt2.Enabled = false
		light1.Color = Color3.fromRGB(254, 56, 59)
		light2.Color = Color3.fromRGB(254, 56, 59)
		task.wait(0.25)
		light1.Color = Color3.fromRGB(254, 254, 254)
		light2.Color = Color3.fromRGB(254, 254, 254)
		task.wait(0.25)
		light1.Color = Color3.fromRGB(254, 56, 59)
		light2.Color = Color3.fromRGB(254, 56, 59)
		task.wait(0.25)
		light1.Color = Color3.fromRGB(254, 254, 254)
		light2.Color = Color3.fromRGB(254, 254, 254)
		-- here is where i need the until variable (if possible)
	end
end)

And no, I don’t want to do it in the script that controls lockdown, because I would have to go through so many loops and it would be complicated.

Thanks :heart:

1 Like

repeat task.wait() until x == true

2 Likes

Doesn’t work, could you give me some sample code?

Also x value is called lockdownvalue

1 Like

assuming you mean samples on how you use repeat–
repeat is like a while loop, except it breaks when a condition is met.

repeat task.wait() until false --this will never finish because the value passed is never true
repeat task.wait() until true --this will finish because the value passed has become true or is true.

to debug your issue you can use this:

repeat
print(lockdownvalue)
task.wait()
until lockdownvalue
1 Like

The value needs to be false; if it is true it will make the door accessible to open

1 Like

i apologize, then you can do:

repeat
task.wait()
until not lockdownvalue
1 Like

Okay so I have this code at the part I commented all the way at the bottom, it doesn’t function properly, heres the code

		repeat
		task.wait()
		until not lockdownvalue
		local lightother1Tween5 = TS:Create(lightother1, colorTweenInfo, {Color = Color3.fromRGB(254, 254, 254)})
		local lightother2Tween5 = TS:Create(lightother2, colorTweenInfo, {Color = Color3.fromRGB(254, 254, 254)})
		lightother1Tween5:Play()
		lightother2Tween5:Play()
		proximityPrompt.Enabled = true
		proximityPrompt2.Enabled = true

EDIT: Maybe it would be better to put some code at the top of the script to make it so it looks like it is locked, so like it always checks if the lockdownvalue == true, if that is possible

1 Like

at the start of the code, you check if lockdownvalue is false if lockdownvalue == false then
you then use else on that condition, that condition will only run if lockdownvalue is true, you’re trying to check if its false in a condition where it’ll always be true

2 Likes

I have this script right now, though it is not working.

local TS = game:GetService("TweenService")

local proximityPrompt = script.Parent
local proximityPrompt2 = proximityPrompt.Parent.Parent.Parent.Reader2.Prox.ProximityPrompt
local left = proximityPrompt.Parent.Parent.Parent.Parent.LeftDoor
local right = proximityPrompt.Parent.Parent.Parent.Parent.RightDoor

local light1 = proximityPrompt.Parent.Parent.ScannerLight1
local light2 = proximityPrompt.Parent.Parent.ScannerLight2

local lightother1 = proximityPrompt.Parent.Parent.Parent.Light1
local lightother2 = proximityPrompt.Parent.Parent.Parent.Light2

local open = right.DoorOpen
local close = right.DoorClose
local deny = right.KeycardDenied
local access = right.KeycardAccepted
local lockdown = right.DoorLockdown

local lockdownvalue = script.Parent.Parent.Parent.Parent.Parent.Parent.Lockdown

local originalPosition1 = left.CFrame
local originalPosition2 = right.CFrame

local targetPosition1 = proximityPrompt.Parent.Parent.Parent.Parent.LeftDoorTween.CFrame
local targetPosition2 = proximityPrompt.Parent.Parent.Parent.Parent.RightDoorTween.CFrame

local tweenInfo = TweenInfo.new(1.5, Enum.EasingStyle.Linear)
local colorTweenInfo = TweenInfo.new(0.75, Enum.EasingStyle.Linear)

local tween1 = TS:Create(left, tweenInfo, {CFrame = targetPosition1})
local tween2 = TS:Create(right, tweenInfo, {CFrame = targetPosition2})
local tween3 = TS:Create(left, tweenInfo, {CFrame = originalPosition1})
local tween4 = TS:Create(right, tweenInfo, {CFrame = originalPosition2})

local requiredAccessLevel = proximityPrompt.Parent.Parent.Parent.Parent.Access.Value

while true do
	if lockdownvalue == true then
		local lightother1Tween4 = TS:Create(lightother1, colorTweenInfo, {Color = Color3.fromRGB(254, 56, 59)})
		local lightother2Tween4 = TS:Create(lightother2, colorTweenInfo, {Color = Color3.fromRGB(254, 56, 59)})
		lightother1Tween4:Play()
		lightother2Tween4:Play()
		lockdown:Play()
		proximityPrompt.Enabled = false
		proximityPrompt2.Enabled = false
		light1.Color = Color3.fromRGB(254, 56, 59)
		light2.Color = Color3.fromRGB(254, 56, 59)
		task.wait(0.25)
		light1.Color = Color3.fromRGB(254, 254, 254)
		light2.Color = Color3.fromRGB(254, 254, 254)
		task.wait(0.25)
		light1.Color = Color3.fromRGB(254, 56, 59)
		light2.Color = Color3.fromRGB(254, 56, 59)
		task.wait(0.25)
		light1.Color = Color3.fromRGB(254, 254, 254)
		light2.Color = Color3.fromRGB(254, 254, 254)
		repeat
			task.wait()
		until not lockdownvalue
		local lightother1Tween5 = TS:Create(lightother1, colorTweenInfo, {Color = Color3.fromRGB(254, 254, 254)})
		local lightother2Tween5 = TS:Create(lightother2, colorTweenInfo, {Color = Color3.fromRGB(254, 254, 254)})
		lightother1Tween5:Play()
		lightother2Tween5:Play()
		proximityPrompt.Enabled = true
		proximityPrompt2.Enabled = true
	end
	task.wait(0.1)
end

proximityPrompt.Triggered:Connect(function(player)
	if lockdownvalue == false then
		local playerData = player:FindFirstChild("Data")
		if playerData then
			local playerAccessLevel = playerData:FindFirstChild("Access")
			if playerAccessLevel and playerAccessLevel.Value >= requiredAccessLevel then
				local light1Tween = TS:Create(light1, colorTweenInfo, {Color = Color3.fromRGB(123, 255, 75)})
				local light2Tween = TS:Create(light2, colorTweenInfo, {Color = Color3.fromRGB(123, 255, 75)})
				local lightother1Tween = TS:Create(lightother1, colorTweenInfo, {Color = Color3.fromRGB(123, 255, 75)})
				local lightother2Tween = TS:Create(lightother2, colorTweenInfo, {Color = Color3.fromRGB(123, 255, 75)})

				proximityPrompt.Enabled = false
				proximityPrompt2.Enabled = false
				access:Play()

				light1Tween:Play()
				light2Tween:Play()
				lightother1Tween:Play()
				lightother2Tween:Play()

				task.wait(1.25)
				open:Play()

				tween1:Play()
				tween2:Play()

				task.wait(4)

				local light1Tween2 = TS:Create(light1, colorTweenInfo, {Color = Color3.fromRGB(245, 255, 60)})
				local light2Tween2 = TS:Create(light2, colorTweenInfo, {Color = Color3.fromRGB(245, 255, 60)})
				local lightother1Tween2 = TS:Create(lightother1, colorTweenInfo, {Color = Color3.fromRGB(245, 255, 60)})
				local lightother2Tween2 = TS:Create(lightother2, colorTweenInfo, {Color = Color3.fromRGB(245, 255, 60)})

				light1Tween2:Play()
				light2Tween2:Play()
				lightother1Tween2:Play()
				lightother2Tween2:Play()

				tween3:Play()
				tween4:Play()

				close:Play()
				task.wait(1.5)

				local light1Tween3 = TS:Create(light1, colorTweenInfo, {Color = Color3.fromRGB(254, 254, 254)})
				local light2Tween3 = TS:Create(light2, colorTweenInfo, {Color = Color3.fromRGB(254, 254, 254)})
				local lightother1Tween3 = TS:Create(lightother1, colorTweenInfo, {Color = Color3.fromRGB(254, 254, 254)})
				local lightother2Tween3 = TS:Create(lightother2, colorTweenInfo, {Color = Color3.fromRGB(254, 254, 254)})

				light1Tween3:Play()
				light2Tween3:Play()
				lightother1Tween3:Play()
				lightother2Tween3:Play()

				task.wait(1)

				proximityPrompt.Enabled = true
				proximityPrompt2.Enabled = true
			else
				deny:Play()
				proximityPrompt.Enabled = false
				proximityPrompt2.Enabled = false
				light1.Color = Color3.fromRGB(254, 56, 59)
				light2.Color = Color3.fromRGB(254, 56, 59)
				task.wait(0.1)
				light1.Color = Color3.fromRGB(254, 254, 254)
				light2.Color = Color3.fromRGB(254, 254, 254)
				task.wait(0.1)
				light1.Color = Color3.fromRGB(254, 56, 59)
				light2.Color = Color3.fromRGB(254, 56, 59)
				task.wait(0.1)
				light1.Color = Color3.fromRGB(254, 254, 254)
				light2.Color = Color3.fromRGB(254, 254, 254)
				task.wait(0.1)
				light1.Color = Color3.fromRGB(254, 56, 59)
				light2.Color = Color3.fromRGB(254, 56, 59)
				task.wait(0.1)
				light1.Color = Color3.fromRGB(254, 254, 254)
				light2.Color = Color3.fromRGB(254, 254, 254)
				task.wait(2)
				proximityPrompt.Enabled = true
				proximityPrompt2.Enabled = true
			end
		else
			player:Kick("Data failed to load, please rejoin")
		end
	else
		--[[ local lightother1Tween4 = TS:Create(lightother1, colorTweenInfo, {Color = Color3.fromRGB(254, 56, 59)})
		local lightother2Tween4 = TS:Create(lightother2, colorTweenInfo, {Color = Color3.fromRGB(254, 56, 59)})
		lightother1Tween4:Play()
		lightother2Tween4:Play()
		lockdown:Play()
		proximityPrompt.Enabled = false
		proximityPrompt2.Enabled = false
		light1.Color = Color3.fromRGB(254, 56, 59)
		light2.Color = Color3.fromRGB(254, 56, 59)
		task.wait(0.25)
		light1.Color = Color3.fromRGB(254, 254, 254)
		light2.Color = Color3.fromRGB(254, 254, 254)
		task.wait(0.25)
		light1.Color = Color3.fromRGB(254, 56, 59)
		light2.Color = Color3.fromRGB(254, 56, 59)
		task.wait(0.25)
		light1.Color = Color3.fromRGB(254, 254, 254)
		light2.Color = Color3.fromRGB(254, 254, 254)
		repeat
			task.wait()
		until not lockdownvalue
		local lightother1Tween5 = TS:Create(lightother1, colorTweenInfo, {Color = Color3.fromRGB(254, 254, 254)})
		local lightother2Tween5 = TS:Create(lightother2, colorTweenInfo, {Color = Color3.fromRGB(254, 254, 254)})
		lightother1Tween5:Play()
		lightother2Tween5:Play()
		proximityPrompt.Enabled = true
		proximityPrompt2.Enabled = true --]]
	end
end)

Tested.

1 Like

I also apologize for failing to realize this, you need to put
lockdownvalue = script.Parent.Parent.Parent.Parent.Parent.Parent.Lockdown
inside the repeat loops to update its value something like:

repeat
lockdownvalue = script.Parent.Parent.Parent.Parent.Parent.Parent.Lockdown
task.wait()
until lockdownvalue
2 Likes

and what exactly is lockdownvalue?

That’s not the part that doesn’t function, it just fails to function as soon as I join the game.

A boolvalue located in a folder.

image

you have to do lockdownvalue.Value

1 Like

You will need a silyhober varible. OK. In that Replicated.

Hold on a minute, I just deactivated the lockdown value and the whole script still doesn’t work. Am I missing something?

Can you rephrase that? That wasn’t even proper english

You will need a Sillygober variable. OK, in that ReplicatedStorage. Thank

is this a local or server script

Server script. Here, I’ll give my explorer:

image

can you make a new script and label it as ‘Debugger’ im going to write some basic debugging code based on your script