I've made a request system that saves a string(The request) inside a datastore under a player's userID. Is there any way I could make a function that gathers all of the requests?
local Plrs = game:GetService("Players")
local DSS = game:GetService("DataStoreService")
local SSS = game:GetService("ServerScriptService")
local RS = game:GetService("ReplicatedStorage")
local Requests = DSS:GetDataStore("Requests")
local PlayerChange = RS:FindFirstChild("PlayerChange")
local RequestSaved = "Request sent! Keep in mind that requests get overwritten, so only the latest message is saved."
local RequestError = "There seems to be an error, try messaging me on Roblox and I will look at the request there."
local ignorepopups = {}
Plrs.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local split = msg:split(" ")
if string.lower(split[1]) == ".request" then
local plrID = plr.Name.."_"..plr.UserId
local NewMessage = ""
for i = 9,#msg,1 do
NewMessage = NewMessage..string.sub(msg,i,i)
end
local success, errormsg = pcall(function()
Requests:SetAsync(plrID, NewMessage)
end)
local message
if success then
if table.find(ignorepopups, plr.UserId) == nil then
message = RequestSaved
local ResponseUI = script.Response:Clone()
ResponseUI.Response.Value = message
ResponseUI.Parent = plr.PlayerGui
end
print("successfully saved")
else
if table.find(ignorepopups, plr.UserId) == nil then
message = RequestError
local ResponseUI = script.Response:Clone()
ResponseUI.Response.Value = message
ResponseUI.Parent = plr.PlayerGui
end
print(errormsg)
end
end
end)
plr.CharacterAppearanceLoaded:Connect(function()
if table.find(ignorepopups, plr.UserId) == nil then
wait(3)
script.Question:Clone().Parent = plr.PlayerGui
end
end)
end)
PlayerChange.OnServerEvent:Connect(function(plr, str)
if string.lower(str) == "ignorepopups" then
local statement = (table.find(ignorepopups, plr.UserId) == nil)
print(statement)
if statement then
table.insert(ignorepopups, #ignorepopups+1, plr.UserId)
elseif not statement then
table.remove(ignorepopups, table.find(ignorepopups, plr.UserId))
end
end
end)
^This is the whole script as of right now
