Hi everyone! i’ve made a door randomizer for a minigame wich takes 3 locked doors, 2 trapped doors and 2 unlocked doors for every row of doors
The issue: i would like to change a little bit my script and add the possibility to have 0 to 2 trapped doors and so on with the locked ones, so the number will be always randomized and not always the same number of locked/trapped doors, here is the script i’m using
function Line()
local OpenDoors = {L1L.Door1, L1L.Door2, L1L.Door3, L1L.Door4, L1L.Door5, L1L.Door6, L1L.Door7}
local LockedDoors = {}
local TrappedDoors = {}
local m = 0
local b = 8
local m2 = 0
local b2 = 5
print("The extracted numbers are:")
repeat
m = m +1
b = b -1
local n = math.random(1,b)
table.move(OpenDoors,n,n,m,LockedDoors)
table.remove(OpenDoors,n)
wait(.5)
until m == 3
repeat
m2 = m2 +1
b2 = b2 -1
local n2 = math.random(1,b2)
table.move(OpenDoors,n2,n2,m2,TrappedDoors)
table.remove(OpenDoors,n2)
wait(.5)
until m2 == 2
print("----------")
print("Locked Doors:")
print(LockedDoors[1])
print(LockedDoors[2])
print(LockedDoors[3])
print("----------")
print("Opened Doors:")
print(OpenDoors[1])
print(OpenDoors[2])
print("----------")
print("Trapped Doors:")
print(TrappedDoors[1])
print(TrappedDoors[2])
print("----------")
for Door, Part in pairs(LockedDoors) do
Part.Part1.BrickColor = BrickColor.new("Really red")
Part.Part2.BrickColor = BrickColor.new("Really red")
Part.Part3.BrickColor = BrickColor.new("Really red")
Part.Part4.BrickColor = BrickColor.new("Really red")
Part.Part1.Anchored = true
Part.Part2.Anchored = true
Part.Part3.Anchored = true
Part.Part4.Anchored = true
end
for Door, Part in pairs(OpenDoors) do
Part.Part1.BrickColor = BrickColor.new("Bright green")
Part.Part2.BrickColor = BrickColor.new("Bright green")
Part.Part3.BrickColor = BrickColor.new("Bright green")
Part.Part4.BrickColor = BrickColor.new("Bright green")
Part.Part1.Anchored = false
Part.Part2.Anchored = false
Part.Part3.Anchored = false
Part.Part4.Anchored = false
end
for Door, Part in pairs(TrappedDoors) do
Part.Part1.BrickColor = BrickColor.new("Cyan")
Part.Part2.BrickColor = BrickColor.new("Cyan")
Part.Part3.BrickColor = BrickColor.new("Cyan")
Part.Part4.BrickColor = BrickColor.new("Cyan")
Part.Part1.Anchored = false
Part.Part2.Anchored = false
Part.Part3.Anchored = false
Part.Part4.Anchored = false
local OriginalTrap = script.Parent.Traps.OriginalTrap
local Copy = OriginalTrap:Clone()
Copy.Parent = OriginalTrap.Parent
local OriginalPositionX = Part.PrimaryPart.Position.x
local OriginalPositionY = Part.PrimaryPart.Position.y
local OriginalPositionZ = Part.PrimaryPart.Position.z
local NewPositionX = OriginalPositionX +13
local NewPositionY = OriginalPositionY -6
local NewPositionZ = OriginalPositionZ -3
print(OriginalPositionX,OriginalPositionY,OriginalPositionZ)
print(NewPositionX,NewPositionY,NewPositionZ)
Copy:MoveTo(Vector3.new (NewPositionX,NewPositionY,NewPositionZ))
end
end
As you can see the (m) variable is the number of how many doors will be in that row, so can be changed to 1 and 2 without problem but when i try to change
until m2 == 2
to
until m2 == math.random(1,2)
i have an error, does anyone know how to make this?
Here is a video on how this script works
robloxapp-20200824-1647219.wmv (661,7 KB)