Hello, so basically I wanted to shorten a small code between line 12 and 19 because I think having them being duplicated multiple times is pretty unnecessary. Is there a way to shorten it?
function dooropen.Scattered(number)
local code = game:GetService("ReplicatedStorage"):WaitForChild("RoomCodes"):FindFirstChild("Room"..number)
local randomenabled = game.Workspace.CodeInput.CodeGivers.Scattered["CodeGiver_"..number].Configuration.Random
local total = game.Workspace.CodeInput.CodeGivers.Scattered["CodeGiver_"..number].Configuration.Total
local scattered = game.Workspace.CodeInput.CodeGivers.Scattered["CodeGiver_"..number].Configuration.ScatteredNumbers
local giver = game.Workspace.CodeInput.CodeGivers.Scattered["CodeGiver_"..number]
if randomenabled.Value == true then
for i = 1, total.Value do
task.wait()
scattered[i].Value = math.random(0, 9)
code.Value = scattered[1].Value..scattered[2].Value..scattered[3].Value..scattered[4].Value..scattered[5].Value..scattered[6].Value
wait(0.5)
giver["Scattered"..i].SurfaceGui.SIGN.Text = i..") "..tostring(scattered[i].Value)
end
else
for i = 1, total.Value do
task.wait()
code.Value = scattered[1].Value..scattered[2].Value..scattered[3].Value..scattered[4].Value..scattered[5].Value..scattered[6].Value
giver["Scattered"..i].SurfaceGui.SIGN.Text = i..") "..tostring(scattered[i].Value)
end
end
end