I need help1
I need help! I want to check if they are banned or not. If they are unbanned it will remove their datastore key however if they are still banned it continues with the code. I already know how to set the data, just not getting the temporary data.
We store data in days and -1 is for permanent bans. Help would be appreciated.
local datastore = game:GetService("DataStoreService"):GetDataStore("TravelodgeBans")
local api = require(game.ServerScriptService.TrelloAPI)
game.Players.PlayerAdded:Connect(function(plr)
local datafolder = Instance.new("Folder", plr)
datafolder.Name = "BanData"
local reason = Instance.new("StringValue", datafolder)
reason.Name = "Reason"
local appeal = Instance.new("StringValue", datafolder)
appeal.Name = "Appealable"
local data
local success, err = pcall(function()
data = datastore:GetAsync(plr.UserId)
end)
if success then
if data then
if data["Reason"] then
reason.Value = data["Reason"]
else
reason.Value = "No Reason Provided"
end
if data["Appealable"] then
appeal.Value = data["Appealable"]
else
appeal.Value = "n"
end
local BoardID = api.BoardsAPI.GetBoardID("Appeal Management")
local Pending = api.BoardsAPI.GetListID(BoardID,"Pending")
local Accepted = api.BoardsAPI.GetListID(BoardID,"Accepted")
local Denied = api.BoardsAPI.GetListID(BoardID,"Denied")
if api.CardsAPI.GetCardOnList(Pending,"["..plr.UserId.. "]") then
plr.PlayerGui.ScreenGui.InformationFrame.TextButton:Destroy()
plr.PlayerGui.ScreenGui.InformationFrame.unappealable.Visible = true
plr.PlayerGui.ScreenGui.ConfirmAppealFrame:Destroy()
plr.PlayerGui.ScreenGui.AppealFrame:Destroy()
plr.PlayerGui.ScreenGui.InformationFrame.status.Text = "Under review"
datastore:SetAsync(plr.UserId, {
["Reason"] = data["Reason"],
["Appealable"] = "n"
})
elseif api.CardsAPI.GetCardOnList(Denied,"["..plr.UserId.. "]") then
local CardID = api.CardsAPI.GetCardOnList(Denied,"[" ..plr.UserId.. "]")
api.CardsAPI.DeleteCard(CardID)
plr.PlayerGui.ScreenGui.InformationFrame.status.Text = "Declined"
datastore:SetAsync(plr.UserId, {
["Reason"] = data["Reason"],
["Appealable"] = "y"
})
appeal.Value = "y"
elseif api.CardsAPI.GetCardOnList(Accepted,"[" ..plr.UserId.. "]") then
local CardID = api.CardsAPI.GetCardOnList(Accepted,"[" ..plr.UserId.. "]")
api.CardsAPI.DeleteCard(CardID)
plr.PlayerGui.ScreenGui.InformationFrame.status.Text = "Accepted"
plr.PlayerGui.ScreenGui.InformationFrame.unappealable.Visible = true
plr.PlayerGui.ScreenGui.InformationFrame.TextButton.Visible = false
wait(5)
datastore:RemoveAsync(plr.UserId)
plr:Kick("Congratulations, your appeal was accepted! To make you aware, if you commit any other offences you may be banned without appeal.")
end
else
plr:Kick("Our system reports that you are not banned, please rejoin. If you continue being brought here, contact us on the comm")
end
else
plr:Kick("Error getting ban data. This could be due to roblox Datastores being down. Please try again later.")
end
end)