is there a way to run a while true do loop through a module script?
when I insert a loop blue and red lines appear under everything. I am trying to update it every few seconds. here is my script.```
You’re basically trying to run a code inside a table, try using a function instead.
local module = {}
module.Something = function()
module.Initalizer = ':'
while true do
local admins = {}
for _, spot in pairs(workspace:GetChildren()) do
if string.match(spot.Name, 'OpenSpot%d+') then
table.insert(admins, spot.Value)
end
end
module.Administrators = admins
wait(3)
end
end
}
return module
local system = require(path.to.module)
coroutine.wrap(system.Something)()
print(system.Administrators .. '\n' .. system.Initalizer)
Edit: Since it seem’s that this is inside an admin system try running the module’s function inside the admin’s loader script before the whole system module is required.
(If this isn’t your own admin system your creating)
the only scripts using the other scripts are these two
local Functions = require(script.Parent.KeyFunctions)
wait(1)
local module = {
["GoldSparkles"] = function(input)
local target = Functions.GetPlayerFromName(input[2])
local sparkles = Instance.new("Sparkles",target.Character.Head)
sparkles.SparkleColor = Color3.fromRGB(255, 247, 0)
end,
["Aura"] = function(input)
local target = Functions.GetPlayerFromName(input[2])
local aura = Instance.new("Sparkles",target.Character.Head)
aura.SparkleColor = Color3.fromRGB(255, 247, 0)
end,
}
local function generateModule()
local newModule = {}
for key,value in next, module do
newModule[key:lower()] = value
end
return newModule
end
return generateModule()
end
and this one
while true do
wait(1)
local Settings = require(script:WaitForChild("Settings"))
local Commands = require(script:WaitForChild("CommandsVIP"))
local function parseChat(player, chat)
if Settings.Administrators[player.Name] or Settings.Administrators[player.UserId] then
if chat:sub(1,1) == Settings.Initializer then
local Keywords = chat:sub(2,chat:len()):split(" ")
local Command = Commands[Keywords[1]:lower()]
Command(Keywords)
end
end
end
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:connect(function(message, recipient)
if not recipient then
parseChat(Player, message)
end
end)
end)
end