Hello, I have this code where it will run once I say something in chat. The issue is that when I run this it sends the data for each player individually, is there any way to group this and send it all at once to improve efficiency, and keep the rates within the limits.
game.Players.PlayerAdded:Connect(function(Player)
Player.Chatted:Connect(function(message)
if Player:GetRankInGroup(7402874) >= 35 then
if message== "!Miles" or message== "/e !Miles" or message== "!miles" or message== "/e !miles" then
if game.ReplicatedStorage.PointsSystem.PaidOut.Value == false then
game.ReplicatedStorage.PointsSystem.PaidOut.Value = true
for i, v in pairs(game.Players:GetChildren()) do
local UserID = v.UserId
local Data = HttpService:JSONDecode(HttpService:GetAsync(URL))
if v.Backpack:WaitForChild("NB") then
PointsPerPaypout = PointsPerPaypout*1.5
elseif v.Backpack:WaitForChild("PE") then
PointsPerPaypout = PointsPerPaypout*1.25
else
PointsPerPaypout = PointsPerPaypout
end
v.leaderstats.Points.Value = tonumber(v.leaderstats.Points.Value) + PointsPerPaypout
task.wait()
if Data[tostring(UserID)] then
local Table = {
[UserID] = {
["Miles"] = v.leaderstats.Points.Value
}
}
local data = HttpService:RequestAsync(
{
Url = URL,
Method = "PATCH",
Headers = {
["Content-Type"] = "application/json"
},
Body = HttpService:JSONEncode(Table)
}
)
end
local Clone = game.ReplicatedStorage.PointsSystem.PointsGiven:Clone()
Clone.Parent = v.PlayerGui
end
game.ReplicatedStorage.PointsSystem.AnimateUi:FireAllClients()
end
end
end
end)
end)