DataStore error

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? To be able to understand this and fix it should this occuragain

  2. What is the issue? I got a random error, this is something I’ve never encountered so I need help

  3. What solutions have you tried so far? Tried googling, nothing, devofurum, nothing

error:

504: Data store request successful, but response not formatted correctly

Code:

function checkIfBanned(player:Player)
	local success
	local errorMessage

	success, errorMessage = pcall(function()
		data = banData:GetAsync(player.UserId)
	end)
	
	if success then
		print(data)
		return data
	else
		print("An error occured see below")
		warn(errorMessage)
	end
end

What does player:Player mean? Shouldn’t you just use player for the function?

Maybe just call it as a local function instead as a regular function.

It still gave the same error as before
image

player:Player means I’m defining the type of data that should be passed in the parameter

is there any code above that function, perhaps you have forgotten an end somewhere.

I get it but I’m not sure if it’s the same as an ungrouped function?

game.Players.PlayerAdded:Connect(function(player:Player)

	local success, errorMessage = pcall(function()
		data = banData:GetAsync(player.UserId)
	end)
	
	if success then
		print(data)
		return data
	else
		print("An error occured see below")
		warn(errorMessage)
	end

end)

Heres the full code of the script

--// SERVICES \\
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")

--// VARIABLES \\
local banData = DataStoreService:GetDataStore("banData")
local data

--// FUNCTIONS \\

function banPlayer(player:Player,BannedBy:Player, reason: string)
	if Players:FindFirstChild(player.Name) then
		local success
		local errorMessage

		success, errorMessage = pcall(function()
			local bannedData = {
				['reason'] = reason,
				['BannedBy'] = BannedBy.Name.." ("..tostring(BannedBy.UserId)..")",
				['PlayerName'] = player.Name
			}
			banData:SetAsync(player.UserId, bannedData)
		end)
		
		if success then
			player:Kick(reason)
		else
			print("An error has occured, see below")
			warn(errorMessage)
		end
	end
end

function unbanPlayer(playerId)
	local success
	local errorMessage

	success, errorMessage = pcall(function()
		
		banData:RemoveAsync(playerId)
	end)

	if success then
		return "Player has been unbanned!"
	else
		print("An error has occured, see below")
		warn(errorMessage)
		return errorMessage
	end
end

local function checkIfBanned(player:Player)
	local success
	local errorMessage

	success, errorMessage = pcall(function()
		data = banData:GetAsync(player.UserId)
	end)
	
	if success then
		print(data)
		return data
	else
		print("An error occured see below")
		warn(errorMessage)
	end
end

--// EVENTS \\
Players.PlayerAdded:Connect(function(player)
	-- Check if they are banned
	local banned = checkIfBanned(player)
	print(banned)
	if banned then
		player:Kick(banned.reason)
	end
	
end)