· 4 years ago · Jul 27, 2021, 08:20 PM
1--https://www.roblox.com/library/6753997957/PlateSystem
2
3local dataserv = game:GetService("DataStoreService")
4local store = dataserv:GetDataStore("Plates")
5
6local module = require(script.Resources)
7local trello = require(script.TrelloAPI) -- Trello API is stupid and i hate it, so good luck changing it
8function split(str)
9 local Items = string.split(str, "|")
10 local ItemTable = {}
11
12 for _, Item in pairs(Items) do
13 local Tbl = string.split(Item, ":")
14 ItemTable[Tbl[1]] = Tbl[2]
15 end
16 print(Items)
17 return Items
18end
19
20function getnamefromdata(str)
21 local s = string.format(str)
22 local number = string.find(s,";")
23 return(string.sub(s,1,(number - 1)))
24end
25
26function getplatefromdata(str)
27 local s = string.format(str)
28 local number = string.find(s,";")
29
30 return(string.sub(s,(number+1),string.len(s)))
31end
32
33function getnumberofchildren(path)
34 local num = 0
35 for i,v in pairs(path:GetChildren()) do
36 num += 1
37 end
38
39 return num
40end
41
42game.Players.PlayerAdded:Connect(function(plr)
43 local boardid = trello:GetBoardID("PlateSystem")
44 local key = plr.UserId
45 local cardid = trello:GetCardID(key,boardid)
46 local data = nil
47 if cardid ~= nil then
48 data = trello:GetCardInfo(cardid)
49 end
50 local folder = Instance.new("Folder")
51 folder.Name = "Plates"
52 folder.Parent = plr
53
54 if data ~= nil then
55 print(data)
56 for i,v in pairs(data) do
57 if i == "desc" then
58 local main = split(v)
59 for _,g in pairs(main) do -- _,G because why not, why do people use underscore, you could just use a,b,c,d,e,f,g and so on, WHY THAT
60 local value = Instance.new("StringValue")
61 value.Parent = folder
62 value.Name = getnamefromdata(g)
63 print(value.Name)
64 value.Value = getplatefromdata(g)
65 print(value.Value)
66 end
67 end
68 end
69 end
70end)
71
72game.Players.PlayerRemoving:Connect(function(plr)
73 local data = {}
74 local key = plr.UserId
75 local boardid = trello:GetBoardID("PlateSystem")
76 local folder = plr:FindFirstChild("Plates")
77 local listid = trello:GetListID("Plates",boardid)
78 if folder then
79 print("Found Folder")
80 for i,v in pairs(folder:GetChildren()) do
81 print(v.Name)
82 if v:IsA("StringValue") then
83 table.insert(data,(v.Name..";"..v.Value))
84 v:Destroy()
85 end
86 end
87 repeat wait() until getnumberofchildren(folder) == 0
88 if trello:GetCardID(key,boardid) ~= nil then
89 print("BOARD")
90 local CardID = trello:GetCardID(key,boardid)
91 print(CardID)
92 trello:EditCard(CardID,plr.UserId,table.unpack(data))
93 print("EDITIED CARD")
94 end
95 end
96
97end)
98
99game:BindToClose(function(close)
100 wait(5) -- Insurance
101end)