The Arrest System I Made Is Working Very Slow And Sometimes It Gives Error Can You Help?
Error:
DataStore Request Was Added To Queue. If Request Queue Fills, Further Requests Will Be Dropped. Try Sending Fewer Requests.Key = (mydatastorekey)
Code:
---------// SERVICES //---------
local DTS = game:GetService("DataStoreService")
local ArrestDTS = DTS:GetDataStore("ArrestDataStoree")
local ArrestDTSLog = DTS:GetOrderedDataStore("ArrestDataStoreLogg")
---------// VARIABLES //---------
local normalTeam = game.Teams.Team
local arrestTeam = game.Teams.Arrested
local ArrestRemote = game.ReplicatedStorage.ArrestGuiRemote
local ArrestMainRemote = game.ReplicatedStorage.ArrestRemote
---------// Code //---------
game.Players.PlayerAdded:Connect(function(plr)
local plrDetainedPlr = Instance.new("StringValue",plr)
plrDetainedPlr.Value = "NoOne"
plrDetainedPlr.Name = "plrDetainedPlr"
plr.CharacterAdded:Connect(function(chr)
wait(chr:WaitForChild("HumanoidRootPart"))
local hmnd = chr:WaitForChild("Humanoid")
local plrArrestedValue = Instance.new("BoolValue",plr)
plrArrestedValue.Name = "plrArrested"
game.ReplicatedStorage.ArrestGuiRemoteBack.OnServerEvent:Connect(function(plrr)
if plrr.Name == plr.Name then
plrArrestedValue.Value = false
plr.TeamColor = normalTeam.TeamColor
hmnd.Health = 0
ArrestDTS:RemoveAsync(plr.UserId)
else
end
end)
local Success, errorMessage = pcall(function()
return ArrestDTS:GetAsync(tostring(plr.UserId), "TempArrest")
end)
if Success then
if errorMessage then
plr.TeamColor = arrestTeam.TeamColor
plrArrestedValue.Value = true
repeat wait()
ArrestRemote:FireClient(plr,errorMessage.ArrestStart,errorMessage.ArrestDuration,errorMessage.ArrestReason)
until plrArrestedValue.Value == false
end
end
end)
end)
ArrestMainRemote.OnServerEvent:Connect(function(plr,arrestttime,arrestlenenkisi,arrestzamandlmi,sebep)
if game.Players:FindFirstChild(arrestlenenkisi) then
if game.Players[arrestlenenkisi].Character:FindFirstChild("Humanoid") then
game.Players[arrestlenenkisi].Character["Humanoid"].Health = 0
ArrestDTS:SetAsync(game.Players[arrestlenenkisi].UserId, {ArrestStart = os.time(), ArrestDuration = (arrestttime * arrestzamandlmi), ArrestReason = sebep})
else
print("Error")
end
else
print("Error")
end
end)