I have a piece of code:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DataStoreService = game:GetService("DataStoreService")
local wordsStore = DataStoreService:GetDataStore("words")
wordsStore:SetAsync("words", {"book","bone","happy"})
local function insert(plr, word)
local function update(oldTable)
return table.insert(oldTable, 1 , word)
end
wordsStore:UpdateAsync("words", update)
end
ReplicatedStorage.Insert.OnServerEvent:Connect(insert)
while wait(5) do
for _, v in pairs(table.insert(wordsStore:GetAsync("words"),1,"horse")) do
print(v)
end
end
In the while loop i've set it to:
while wait(5) do
for _, v in pairs(wordsStore:GetAsync("words")) do
print(v)
end
end
And it works, it prints every item in the table but when set it up like this
while wait(5) do
for _, v in pairs(table.insert(wordsStore:GetAsync("words"),1,"horse")) do
print(v)
end
end
It says: ServerScriptService.Script:13: missing argument #1 (table expected) But in the example without the table.insert it recognized it as a table (because the in pairs thingy works) but in table.insert it doesnt and that's why the code to update the table in the beggining doesn't work. How do i fix that?
