Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with DataStore?

Asked by 8 years ago

So I'm trying to make a cross-server chat, and I've only just recently gotten into using data store. So, I've created this exmaple of how i could possibly make one, and i tested it. It sorta works, however the more messages there are, the longer it seemingly takes to cache and load information.

local Players = game:GetService("Players")
local DataStoreService = game:GetService("DataStoreService")
local ChatStore = DataStoreService:GetDataStore("ChatStore")

Players.PlayerAdded:connect(function(p)
    p.Chatted:connect(function(msg)
        ChatStore:UpdateAsync("Chats", function(value)
            table.insert(value, p.Name..': '..msg)
            return value
        end)
    end)
end)

while wait(1) do
    table.foreach(ChatStore:GetAsync("Chats"),print)
end

As you could imagine, that's super problematic when making a chat system. And i have seen cross-server chat systems before that operate at a faster pace, so if anyone knows how i can make this effective or usable, i'd appreciate it. Thanks.

Answer this question