[HELP] Arrest System Not Working

The Arrest System I Made Is Working Very Slow And Sometimes It Gives Error Can You Help?

---------// 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)

Which part of it exactly isn’t working. Can you also post the error from the output?

No have a error from the Output the error of the code is that sometimes it works and sometimes it doesn’t work and it works very slowly

Should I use setasync instead of removeasync?

Can you put a print statement after plr.CharacterAdded:Connect(function(chr) and let me know if it prints it out.
This can be anything like: print("Test")

If it does print, then change your datastore name:
local ArrestDTS = DTS:GetDataStore("ArrestDataStoree") to > local ArrestDTS = DTS:GetDataStore("slate1")
Then see if the print statment works.

Yeah Printing “Test” I Test Change DataStore Name

Yeah Worked But Player Died 2 Times And The team changes after the character dies.

And After Arresting A Few Times It Doesn’t Work Anymore.

Output: DataStore Request Was Added To Queue. If Request Queue Fills, Further Requests Will Be Dropped. Try Sending Fewer Requests.Key = (mydatastorekey)