You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? To be able to understand this and fix it should this occuragain
What is the issue? I got a random error, this is something I’ve never encountered so I need help
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
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)
--// 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)