1+ local Version = " 0.3.0"
2+
3+ local PluginFolder = script .Parent
4+ if not PluginFolder :IsA (" Folder" ) then
5+ error (" Plugin folder is not a folder." )
6+ end
7+ local Assets = PluginFolder .Assets
8+ local rbxts_include = PluginFolder [" rbxts_include" ]
9+ local shared = PluginFolder .shared
10+ local server = PluginFolder .server
11+ local client = PluginFolder .client
12+ local Animations = PluginFolder .Animations
13+ local Animate = PluginFolder .Animate
14+ local PlayerModule = PluginFolder .PlayerModule
15+ Animate .Disabled = true
16+
17+ function ToggleScripts (instance : Instance , bool : boolean )
18+ for _ ,v in pairs (instance :GetDescendants ()) do
19+ if v :IsA (" Script" ) or v :IsA (" LocalScript" ) then
20+ v .Disabled = bool
21+ end
22+ end
23+ end
24+
25+ ToggleScripts (rbxts_include , true )
26+ ToggleScripts (server , true )
27+ ToggleScripts (client , true )
28+ ToggleScripts (shared , true )
29+
30+ local Config = shared .Config :Clone ()
31+ shared .Config :Destroy ()
32+
33+ local toolbar = plugin :CreateToolbar (" AET" )
34+
35+ local Setup = toolbar :CreateButton (" Setup" , " Sets up and updates AET." , " " )
36+ local InitalizeTool = toolbar :CreateButton (" Initalize Tool" , " Initializes a tool." , " " )
37+
38+ Setup .ClickableWhenViewportHidden = true
39+ InitalizeTool .ClickableWhenViewportHidden = true
40+
41+ local ReplicatedStorage = game :GetService (" ReplicatedStorage" )
42+ local Teams = game :GetService (" Teams" )
43+ local ServerScriptService = game :GetService (" ServerScriptService" )
44+ local StarterPlayer = game :GetService (" StarterPlayer" )
45+ local StarterCharacterScripts = StarterPlayer .StarterCharacterScripts
46+ local StarterPlayerScripts = StarterPlayer .StarterPlayerScripts
47+ local ChangeHistoryService = game :GetService (" ChangeHistoryService" )
48+ local Selection = game :GetService (" Selection" )
49+
50+ function DoUpdateScripts ()
51+ local GameInclude = ReplicatedStorage :FindFirstChild (" rbxts_include" )
52+ local GameShared = ReplicatedStorage :FindFirstChild (" shared" )
53+ local GameClient = ServerScriptService :FindFirstChild (" server" )
54+ local GameServer = StarterPlayerScripts :FindFirstChild (" client" )
55+ local GameChar = StarterCharacterScripts :FindFirstChild (" char" )
56+ local newConfig : ModuleScript = GameShared and GameShared .Config :Clone () or Config :Clone ()
57+ newConfig :SetAttribute (" Version" , Version )
58+ local oldConfig = GameShared and GameShared :FindFirstChild (" Config_OLD" ) and GameShared :FindFirstChild (" Config_OLD" ):Clone ()
59+
60+ if GameInclude then
61+ GameInclude :Destroy ()
62+ end
63+
64+ if GameShared then
65+ GameShared :Destroy ()
66+ end
67+
68+ if GameClient then
69+ GameClient :Destroy ()
70+ end
71+
72+ if GameServer then
73+ GameServer :Destroy ()
74+ end
75+
76+ if GameChar then
77+ GameChar :Destroy ()
78+ end
79+
80+ local newServer = server :Clone ()
81+ newServer .Parent = ServerScriptService
82+
83+ local newClient = client :Clone ()
84+ newClient .Parent = StarterPlayerScripts
85+
86+ local newInclude = rbxts_include :Clone ()
87+ newInclude .Parent = ReplicatedStorage
88+
89+ local newAnimate = Animate :Clone ()
90+ local newPlayerModule = PlayerModule :Clone ()
91+
92+ if StarterCharacterScripts :FindFirstChild (" Animate" ) then
93+ StarterCharacterScripts .Animate :Destroy ()
94+ end
95+
96+ if StarterPlayerScripts :FindFirstChild (" PlayerModule" ) then
97+ StarterPlayerScripts .PlayerModule :Destroy ()
98+ end
99+
100+ newAnimate .Parent = StarterCharacterScripts
101+ newPlayerModule .Parent = StarterPlayerScripts
102+ newAnimate .Disabled = false
103+
104+ local newShared = shared :Clone ()
105+ newShared .Parent = ReplicatedStorage
106+
107+ newConfig .Parent = newShared
108+
109+ ToggleScripts (newInclude , false )
110+ ToggleScripts (newServer , false )
111+ ToggleScripts (newClient , false )
112+ ToggleScripts (newShared , false )
113+
114+ if game .Workspace :FindFirstChild (" Animations" ) then
115+ game .Workspace .Animations :Destroy ()
116+ end
117+ local newAnimations = Animations :Clone ()
118+ newAnimations .Parent = game .Workspace
119+
120+
121+ if oldConfig then
122+ oldConfig .Parent = newShared
123+ warn (" You have a config that may need to be updated! If you press setup again your old config will be deleted. OLD:" , oldConfig , " - NEW:" , newConfig )
124+ if oldConfig :GetAttribute (" Version" ) and oldConfig :GetAttribute (" Version" ) == Version then
125+ warn (" You are updating to the same version." )
126+ end
127+ else
128+ warn (" Make sure you export and set new animations. Config:" , newConfig , " - Animations:" , newAnimations )
129+ end
130+
131+ if not game .Workspace :GetAttribute (" AET_INITED" ) then
132+ game .Workspace :SetAttribute (" AET_INITED" , true )
133+ local newTeam = Instance .new (" Team" )
134+ newTeam .Name = " Neutral"
135+ newTeam .TeamColor = BrickColor .new (" Institutional white" )
136+ newTeam .AutoAssignable = true
137+ newTeam .Parent = Teams
138+
139+ local function CreateTeamTool (toolName )
140+ local newModel = Instance .new (" Model" )
141+ newModel .Name = toolName
142+ newModel .Parent = newTeam
143+ end
144+
145+ CreateTeamTool (" Athens" )
146+ CreateTeamTool (" Bow" )
147+ CreateTeamTool (" Dory" )
148+ CreateTeamTool (" Kopis" )
149+ CreateTeamTool (" Roman" )
150+ CreateTeamTool (" Shield" )
151+ CreateTeamTool (" Sparta" )
152+ end
153+ end
154+
155+ function DoUpdateAssets ()
156+ local GameAssets = ReplicatedStorage :FindFirstChild (" Assets" )
157+ if not GameAssets then
158+ local newAssets = Assets :Clone ()
159+ newAssets .Parent = ReplicatedStorage
160+ else
161+ for _ ,v in pairs (Assets :GetChildren ()) do
162+ if GameAssets :FindFirstChild (v .Name ) then
163+ if v .Name == " Tools" then
164+ for _ ,v2 in pairs (Assets .Tools :GetChildren ()) do
165+ if GameAssets .Tools :FindFirstChild (v2 .Name ) then
166+ GameAssets .Tools [v2 .Name ]:Destroy ()
167+ end
168+ local newTool = v2 :Clone ()
169+ newTool .Parent = GameAssets .Tools
170+ end
171+ continue
172+ else
173+ GameAssets [v .Name ]:Destroy ()
174+ end
175+ end
176+
177+ local newV = v :Clone ()
178+ newV .Parent = GameAssets
179+ end
180+ end
181+ end
182+
183+ function DoAddConfig ()
184+ local GameShared = ReplicatedStorage :FindFirstChild (" shared" )
185+ if not GameShared then
186+ GameShared = Instance .new (" Folder" )
187+ GameShared .Name = " shared"
188+ GameShared .Parent = ReplicatedStorage
189+ end
190+ local OldConfig = GameShared :FindFirstChild (" Config" )
191+ if OldConfig then
192+ OldConfig .Name = " Config_OLD"
193+ end
194+ local newConfig = Config :Clone ()
195+ newConfig .Parent = GameShared
196+ newConfig :SetAttribute (" Version" , Version )
197+ end
198+
199+ function DoInitalizeTool ()
200+ local CurrentSelection = Selection :Get ()
201+ if # CurrentSelection ~= 1 then
202+ return warn (" Select only the main model of the tool." )
203+ end
204+ local Tool = CurrentSelection [1 ]
205+ if not Tool :IsA (" Model" ) then
206+ return warn (" Tool selected is not a model" )
207+ end
208+
209+ local Attach : Instance
210+ for _ ,v in pairs (Tool :GetChildren ()) do
211+ if string.find (v .Name , " Attach" ) then
212+ Attach = v
213+ break
214+ end
215+ end
216+
217+ if not Attach then
218+ return warn (" Tool selected does not have an attach." )
219+ end
220+
221+ local parts = {}
222+ for _ ,v in ipairs (Tool :GetDescendants ()) do
223+ if v == Attach then
224+ continue
225+ elseif v :IsA (" BasePart" ) then
226+ parts [# parts + 1 ] = v
227+ elseif v :IsA (" Weld" ) then
228+ warn (" existing weld" ,v ," may cause problems with the new welds being added" )
229+ end
230+ end
231+
232+ if # parts > 0 then
233+ local d = {}
234+ for i = 1 ,# parts do
235+ local p1 ,p0 = Attach ,parts [i ]
236+ p1 .Anchored ,p0 .Anchored = true ,true
237+ local joint = Instance .new (" Weld" )
238+ joint .Part0 = p1
239+ joint .Part1 = p0
240+ joint .C0 = p1 .CFrame :toObjectSpace (p0 .CFrame )
241+ joint .C1 = CFrame .new ()
242+ joint .Parent = p1
243+ joint .Name = p0 .Name
244+ p1 .Anchored ,p0 .Anchored = false ,false
245+ p0 .CanCollide = false
246+ p0 .Massless = true
247+ d [# d + 1 ]= joint
248+ end
249+ Selection :Set (d )
250+ else
251+ return warn (" The tool you are attempting to select does not have any baseparts to be welded." )
252+ end
253+ end
254+
255+ Setup .Click :Connect (function ()
256+ plugin :SelectRibbonTool (Enum .RibbonTool .Select ,UDim2 .new (0 ,0 ,0 ,0 ))
257+ DoAddConfig ()
258+ DoUpdateAssets ()
259+ DoUpdateScripts ()
260+ print (" Succesfully Setup AET" )
261+ ChangeHistoryService :SetWaypoint (" Setup" )
262+ end )
263+
264+ InitalizeTool .Click :Connect (function ()
265+ plugin :SelectRibbonTool (Enum .RibbonTool .Select ,UDim2 .new (0 ,0 ,0 ,0 ))
266+ DoInitalizeTool ()
267+ print (" Succesfully Initialized Tool" )
268+ ChangeHistoryService :SetWaypoint (" InitalizedTool" )
269+ end )
0 commit comments