Advertisement
Kaemi

Untitled

Feb 24th, 2018
424
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.12 KB | None | 0 0
  1.  
  2. --XD
  3. function sandbox(var,func)
  4. local env = getfenv(func)
  5. local newenv = setmetatable({},{
  6. __index = function(self,k)
  7. if k=="script" then
  8. return var
  9. else
  10. return env[k]
  11. end
  12. end,
  13. })
  14. setfenv(func,newenv)
  15. return func
  16. end
  17. cors = {}
  18. mas = Instance.new("Model",game:GetService("Lighting"))
  19. Tool0 = Instance.new("Tool")
  20. LocalScript1 = Instance.new("LocalScript")
  21. ObjectValue2 = Instance.new("ObjectValue")
  22. Part3 = Instance.new("Part")
  23. SpecialMesh4 = Instance.new("SpecialMesh")
  24. Sound5 = Instance.new("Sound")
  25. Sound6 = Instance.new("Sound")
  26. Sound7 = Instance.new("Sound")
  27. Sound8 = Instance.new("Sound")
  28. Sound9 = Instance.new("Sound")
  29. Sound10 = Instance.new("Sound")
  30. ObjectValue11 = Instance.new("ObjectValue")
  31. Tool0.Name = "Insert Tool Prototype"
  32. Tool0.Parent = mas
  33. Tool0.TextureId = "rbxasset://icons/insert.png"
  34. Tool0.GripForward = Vector3.new(-1, 0, -0)
  35. Tool0.GripPos = Vector3.new(0.600000024, 0.200000003, 0)
  36. Tool0.GripRight = Vector3.new(0, 0, -1)
  37. LocalScript1.Name = "Insert Local"
  38. LocalScript1.Parent = Tool0
  39. table.insert(cors,sandbox(LocalScript1,function()
  40. local Tool = script.Parent
  41.  
  42. --game:GetService("InsertService"):SetCollectionUrl("http://test.roblox.com/Game/Tools/insertasset.ashx?sid=%d")
  43. --game:GetService("InsertService"):SetBaseCategoryUrl("http://test.roblox.com/Game/Tools/insertasset.ashx?nsets=10")
  44. --game:GetService("InsertService"):SetAssetUrl("http://test.roblox.com/Asset/?id=%d")
  45.  
  46. enabled = true
  47. local origTexture = Tool.TextureId
  48. game:GetService("ContentProvider"):Preload("rbxasset://icons/insert_sel.png")
  49.  
  50. local height = 20
  51. local width = UDim.new(0.25, 0)
  52. local height = 20
  53. local buttonTransparency = 0.1
  54. local insertButtonTransparency = 0.25
  55. local transparency = 0.25
  56.  
  57. local selectedButtonColor = Color3.new(0, 0, 0)
  58. local selectedButtonTextColor = Color3.new(1,1,1)
  59.  
  60. local buttonColor = Color3.new(0, 0, 0)
  61. local buttonTextColor = Color3.new(1.0,1.0,1.0)
  62.  
  63. local frameColor = Color3.new(0, 0, 0)
  64. local frameTextColor = Color3.new(1.0,1.0,1.0)
  65.  
  66. local titleColor = Color3.new(0, 0, 0)
  67. local titleTextColor = Color3.new(1,1,1)
  68.  
  69. local Window
  70. local Data
  71. local Mouse
  72.  
  73. local SetCache = {}
  74.  
  75. local soloGame = game:FindFirstChild("NetworkClient") == nil
  76.  
  77. --Constants
  78. local useAssetVersionId = true
  79. local BaseUrl = game:GetService("ContentProvider").BaseUrl
  80. local ThumbnailUrl;
  81. if useAssetVersionId then
  82. ThumbnailUrl = BaseUrl .. "Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=110&ht=110&assetversionid="
  83. else
  84. ThumbnailUrl = BaseUrl .. "Game/Tools/ThumbnailAsset.ashx?fmt=png&wd=110&ht=110&aid="
  85. end
  86.  
  87. local InsertRows = 4
  88. local InsertColumns = 8
  89.  
  90. --Static variables used for creating sizes
  91. function getPlayer()
  92. local character = script.Parent.Parent
  93. return game.Players:GetPlayerFromCharacter(character)
  94. end
  95.  
  96. function minimize()
  97. if Window.Stamp.Frame.Visible then
  98. cancelAssetPlacement()
  99. elseif Window.Main.Frame.Visible then
  100. Window.Main.Frame.Visible = false
  101. Window.Minimized.Frame.Visible = true
  102. end
  103. end
  104.  
  105. function buildImageButton(image)
  106. local buttonFrame = Instance.new("Frame")
  107. buttonFrame.BackgroundTransparency = 1.0
  108.  
  109. local button = Instance.new("ImageButton")
  110. button.Name = "Button"
  111. button.Parent = buttonFrame
  112. button.Image = image
  113. button.Size = UDim2.new(1.0, 0, 1.0, 0)
  114. button.Position = UDim2.new(0.0, 0, 0.0, 0)
  115. button.BorderSizePixel = 1
  116. button.Parent = buttonFrame
  117. button.BackgroundTransparency = 0
  118.  
  119. return buttonFrame
  120.  
  121. end
  122. function buildTextButton(text)
  123.  
  124. local buttonFrame = Instance.new("Frame")
  125. buttonFrame.BackgroundTransparency = 1.0
  126. local button = Instance.new("TextButton")
  127. button.Name = "Button"
  128. button.Style = "RobloxButton"
  129. button.Parent = buttonFrame
  130. button.Text = text
  131. button.Size = UDim2.new(1.0, 0, 1.0, 0)
  132. button.TextWrap = true
  133. button.Position = UDim2.new(0.0, 0, 0.0, 0)
  134. button.BorderSizePixel = 1
  135. button.BackgroundTransparency = buttonTransparency
  136. button.Parent = buttonFrame
  137.  
  138. return buttonFrame
  139. end
  140.  
  141. function mouseEnterInsertButton(insertFrame)
  142. if insertFrame ~= Data.CurrentRolloverInsertButton then
  143. insertFrame.Button.Transparency = 0.0
  144. Data.CurrentRolloverInsertButton = insertFrame
  145. Window.Main.RolloverText.Text = Data.CurrentRolloverInsertButton.AssetName.Value
  146. end
  147. end
  148.  
  149. function mouseLeaveInsertButton(insertFrame)
  150. if insertFrame == Data.CurrentRolloverInsertButton then
  151. Window.Main.RolloverText.Text = ""
  152. Data.CurrentRolloverInsertButton = nil
  153.  
  154. end
  155. insertFrame.Button.Transparency = insertButtonTransparency
  156. end
  157.  
  158. function buildInsertButton(position, size)
  159. local insertFrame = buildImageButton("")
  160. insertFrame.Name = "InsertAssetButton"
  161. insertFrame.Position = position
  162. insertFrame.Size = size
  163. insertFrame.Button.BackgroundColor3 = Color3.new(1.0,1.0,1.0)
  164. insertFrame.Button.Transparency = insertButtonTransparency
  165. insertFrame.Visible = false
  166.  
  167. local assetId = Instance.new("IntValue")
  168. assetId.Name = "AssetId"
  169. assetId.Value = -1
  170. assetId.Parent = insertFrame
  171.  
  172. local assetName = Instance.new("StringValue")
  173. assetName.Name = "AssetName"
  174. assetName.Value = ""
  175. assetName.Parent = insertFrame
  176.  
  177. insertFrame.Button.MouseButton1Click:connect(function() mouseLeaveInsertButton(insertFrame) beginInsertAsset(insertFrame.AssetName.Value, insertFrame.AssetId.Value, insertFrame.Button.Image, false) end)
  178. insertFrame.Button.MouseButton2Click:connect(function() mouseLeaveInsertButton(insertFrame) beginInsertAsset(insertFrame.AssetName.Value, insertFrame.AssetId.Value, insertFrame.Button.Image, true) end)
  179. insertFrame.Button.MouseEnter:connect(function() mouseEnterInsertButton(insertFrame) end)
  180. insertFrame.Button.MouseLeave:connect(function() mouseLeaveInsertButton(insertFrame) end)
  181.  
  182. return insertFrame
  183. end
  184.  
  185. function setInsertButtonImageBehavior(insertFrame, visible, name, assetId)
  186. if visible then
  187. insertFrame.AssetName.Value = name
  188. insertFrame.AssetId.Value = assetId
  189. insertFrame.Button.Image = ThumbnailUrl .. assetId
  190. insertFrame.Button.BackgroundColor3 = Color3.new(1.0,1.0,1.0)
  191. insertFrame.Visible = true
  192. else
  193. insertFrame.Visible = false
  194. end
  195. end
  196.  
  197. function mouseEnterSetButton(setFrame)
  198. if setFrame.Button.AutoButtonColor then
  199. setFrame.Button.Icon.Transparency = 0.0
  200. end
  201. end
  202. function mouseLeaveSetButton(setFrame)
  203. if setFrame.Button.AutoButtonColor then
  204. setFrame.Button.Icon.Transparency = insertButtonTransparency
  205. end
  206. end
  207.  
  208. function buildSetButton(name, setId, setImageId, i, count)
  209. local buttonFrame = buildTextButton("")
  210. buttonFrame.Name = "SetButton"
  211. buttonFrame.Size = UDim2.new(1.0, 0, 0.0, height*2)
  212. buttonFrame.Position = UDim2.new(0.0, 0, 0.0, (i-1)*height*2)
  213. buttonFrame.Button.BackgroundColor3 = buttonColor
  214. buttonFrame.Button.TextColor3 = buttonTextColor
  215. buttonFrame.Visible = false
  216.  
  217. local setNameLabel = Instance.new("TextLabel")
  218. setNameLabel.Name = "Name"
  219. setNameLabel.Font = "ArialBold"
  220. setNameLabel.FontSize = "Size14"
  221. setNameLabel.Text = name
  222. setNameLabel.TextColor3 = buttonTextColor
  223. setNameLabel.BackgroundTransparency = 1.0
  224. setNameLabel.Size = UDim2.new(1.0, 0, 1.0, 0.0)
  225. setNameLabel.Position = UDim2.new(0.0, 20, 0.0, 0)
  226. setNameLabel.TextWrap = true
  227. setNameLabel.TextXAlignment = Enum.TextXAlignment.Left
  228. setNameLabel.Parent = buttonFrame.Button
  229.  
  230. local iconLabel = Instance.new("ImageLabel")
  231. iconLabel.Name = "Icon"
  232. iconLabel.Image = BaseUrl .. "asset/?id=" .. setImageId
  233. iconLabel.Size = UDim2.new(0.0, 25 , 0.0, 25)
  234. iconLabel.Position = UDim2.new(0.0, -6, 0.0, -5)
  235. iconLabel.Transparency = insertButtonTransparency
  236. iconLabel.Parent = buttonFrame.Button
  237.  
  238. local setValue = Instance.new("IntValue")
  239. setValue.Name = "SetId"
  240. setValue.Value = setId
  241. setValue.Parent = buttonFrame
  242.  
  243. local setName = Instance.new("StringValue")
  244. setName.Name = "SetName"
  245. setName.Value = name
  246. setName.Parent = buttonFrame
  247.  
  248. buttonFrame.Button.MouseButton1Click:connect(function() selectSet(buttonFrame, buttonFrame.SetName.Value, buttonFrame.SetId.Value, 0) end)
  249. buttonFrame.Button.MouseEnter:connect(function() mouseEnterSetButton(buttonFrame) end)
  250. buttonFrame.Button.MouseLeave:connect(function() mouseLeaveSetButton(buttonFrame) end)
  251.  
  252. --print("Built button " .. i .. " SetId=" .. setId .. " SetName=" .. name)
  253.  
  254. return buttonFrame
  255. end
  256.  
  257. function previousSetPage()
  258. local newIndex = math.max(1, Data.Category[Data.CurrentCategory].Index - (Data.Main.InsertRows * Data.Main.InsertColumns))
  259. setSetIndex(newIndex)
  260. end
  261.  
  262. function nextSetPage()
  263. local newIndex = math.max(0, Data.Category[Data.CurrentCategory].Index + (Data.Main.InsertRows * Data.Main.InsertColumns))
  264. setSetIndex(newIndex)
  265. end
  266.  
  267. function setSetIndex(dataOffset)
  268. Data.Category[Data.CurrentCategory].Index = dataOffset
  269.  
  270. local PageSize = Data.Main.InsertRows*Data.Main.InsertColumns
  271. local contents = Data.Category[Data.CurrentCategory].Contents
  272. if contents then
  273. for index = 1, PageSize do
  274. if Data.InsertButtons[index] then
  275. if contents[index + dataOffset] then
  276. --for key, value in pairs(contents[index+dataOffset]) do
  277. -- print("key=" .. key .. ", value=" .. value)
  278. --end
  279.  
  280. local assetId
  281. if useAssetVersionId then
  282. assetId = contents[index + dataOffset].AssetVersionId
  283. else
  284. assetId = contents[index + dataOffset].AssetId
  285. end
  286. setInsertButtonImageBehavior(Data.InsertButtons[index], true, contents[index + dataOffset].Name, assetId)
  287. else
  288. setInsertButtonImageBehavior(Data.InsertButtons[index], false)
  289. end
  290. end
  291. end
  292. Window.Main.PreviousPageButton.Visible = dataOffset > 0
  293. Window.Main.NextPageButton.Visible = (dataOffset + PageSize) < (#contents)
  294. else
  295. Window.Main.PreviousPageButton.Visible = false
  296. Window.Main.NextPageButton.Visible = false
  297. end
  298. end
  299.  
  300. function previousCategoryPage()
  301. local newIndex = math.max(0, Data.Category[Data.CurrentCategory].SetIndex - Data.Main.InsertSets)
  302. setCategoryIndex(newIndex)
  303. end
  304.  
  305. function nextCategoryPage()
  306. local newIndex = math.max(0, Data.Category[Data.CurrentCategory].SetIndex + Data.Main.InsertSets)
  307. setCategoryIndex(newIndex)
  308. end
  309.  
  310. function setCategoryIndex(setIndex)
  311. Data.Category[Data.CurrentCategory].SetIndex = setIndex
  312. --This is how many vertical items we can display
  313.  
  314. --Layout all buttons in this setoh
  315. if #Data.CurrentCategory > Data.Main.InsertSets then
  316. --Steal one for use by the layout buttons, when it rains it pours
  317.  
  318. --We can't fit all the buttons
  319. local heightUsed = 0
  320.  
  321. local index = 1
  322. if index < setIndex then
  323. heightUsed = height
  324. Window.Main.PreviousSetButton.Visible = true
  325. while index < setIndex do
  326. Data.CurrentCategory[index].Visible = false
  327. index = index + 1
  328. end
  329. else
  330. Window.Main.PreviousSetButton.Visible = false
  331. end
  332.  
  333. local offset = 0
  334. while offset < Data.Main.InsertSets and index + offset <= #Data.CurrentCategory do
  335. Data.CurrentCategory[index + offset].Size = UDim2.new(1.0, 0, 0.0, height*2)
  336. Data.CurrentCategory[index + offset].Position = UDim2.new(0.0, 0, 0.0, height*2*offset + heightUsed)
  337. Data.CurrentCategory[index + offset].Visible = true
  338. offset = offset + 1
  339. end
  340. index = index + offset
  341. heightUsed = heightUsed + Data.Main.InsertSets*height*2
  342.  
  343. if index <= #Data.CurrentCategory then
  344. Window.Main.NextSetButton.Position = UDim2.new(0.0, 0, 0.0, heightUsed)
  345. Window.Main.NextSetButton.Size = UDim2.new(1.0, 0, 1.0, -heightUsed)
  346. Window.Main.NextSetButton.Visible = true
  347. while index <= #Data.CurrentCategory do
  348. Data.CurrentCategory[index].Visible = false
  349. index = index + 1
  350. end
  351. else
  352. Window.Main.NextSetButton.Visible = false
  353. end
  354. --Window.Main.Frame.SetTab.SetFiller.Size = UDim2.new(0.0, 0, 0.0, 0)
  355. else
  356. Window.Main.PreviousSetButton.Visible = false
  357. Window.Main.NextSetButton.Visible = false
  358.  
  359. for key, buttonFrame in pairs(Data.CurrentCategory) do
  360. buttonFrame.Size = UDim2.new(1.0, 0, 0.0, height*2)
  361. buttonFrame.Position = UDim2.new(0.0, 0, 0.0, height*2*(key-1))
  362. buttonFrame.Visible = true
  363. end
  364.  
  365. --Then expand this to fill the remaining space at the bottom
  366. --Window.Main.Frame.SetTab.SetFiller.Position = UDim2.new(0.0, 0, 0.0, height*2*#Data.CurrentCategory)
  367. --Window.Main.Frame.SetTab.SetFiller.Size = UDim2.new(1.0, 0, 0.0, frameHeight - height*2*#Data.CurrentCategory)
  368. end
  369. end
  370.  
  371. function selectCategoryPage(buttons, page)
  372. if buttons ~= Data.CurrentCategory then
  373. if Data.CurrentCategory then
  374. for key, button in pairs(Data.CurrentCategory) do
  375. button.Visible = false
  376. end
  377. end
  378.  
  379. Data.CurrentCategory = buttons
  380. if Data.Category[Data.CurrentCategory] == nil then
  381. Data.Category[Data.CurrentCategory] = {}
  382. if #buttons > 0 then
  383. selectSet(buttons[1], buttons[1].SetName.Value, buttons[1].SetId.Value, 0)
  384. end
  385. else
  386. Data.Category[Data.CurrentCategory].Button = nil
  387. selectSet(Data.Category[Data.CurrentCategory].ButtonFrame, Data.Category[Data.CurrentCategory].SetName, Data.Category[Data.CurrentCategory].SetId, Data.Category[Data.CurrentCategory].Index)
  388. end
  389. if Data.Main.FrameHeight then
  390. if Data.Category[Data.CurrentCategory].SetIndex then
  391. layoutSetButtons(Data.Main.FrameHeight, Data.Category[Data.CurrentCategory].SetIndex)
  392. else
  393. layoutSetButtons(Data.Main.FrameHeight, 1)
  394. end
  395. end
  396.  
  397.  
  398. end
  399. end
  400. function filterSet(set)
  401. if soloGame then
  402. return set
  403. end
  404.  
  405. local result = {}
  406. for pos, object in pairs(set) do
  407. if object.IsTrusted then
  408. result[#result+1] = object
  409. end
  410. end
  411. return result
  412. end
  413. function selectSet(buttonFrame, setName, setId, setIndex)
  414. if buttonFrame then
  415. if buttonFrame.Button ~= Data.Category[Data.CurrentCategory].Button then
  416. if Data.Category[Data.CurrentCategory].Button ~= nil then
  417. Data.Category[Data.CurrentCategory].Button.BackgroundColor3 = buttonColor
  418. Data.Category[Data.CurrentCategory].Button.TextColor3 = selectedButtonTextColor
  419. Data.Category[Data.CurrentCategory].Button.Icon.Transparency = insertButtonTransparency
  420. Data.Category[Data.CurrentCategory].Button.AutoButtonColor = true
  421. Data.Category[Data.CurrentCategory].Button.Style = "RobloxButton"
  422.  
  423. end
  424.  
  425. Data.Category[Data.CurrentCategory].Button = buttonFrame.Button
  426. Data.Category[Data.CurrentCategory].Button.BackgroundColor3 = selectedButtonColor
  427. Data.Category[Data.CurrentCategory].Button.TextColor3 = selectedButtonTextColor
  428. Data.Category[Data.CurrentCategory].Button.Icon.Transparency = 0.0
  429. Data.Category[Data.CurrentCategory].Button.AutoButtonColor = false
  430. Data.Category[Data.CurrentCategory].Button.Style = "RobloxButtonDefault"
  431.  
  432. if SetCache[setId] == nil then
  433. SetCache[setId] = filterSet(game:GetService("InsertService"):GetCollection(setId))
  434. end
  435. Data.Category[Data.CurrentCategory].Contents = SetCache[setId]
  436. Window.Main.Title.Text = setName
  437.  
  438. Data.Category[Data.CurrentCategory].SetName = setName
  439. Data.Category[Data.CurrentCategory].SetId = setId
  440. Data.Category[Data.CurrentCategory].ButtonFrame = buttonFrame
  441. end
  442.  
  443. setSetIndex (setIndex)
  444. end
  445. end
  446.  
  447. function selectCategory(button, category)
  448. if Data.CurrentCategory ~= category then
  449. if Data.CurrentCategoryButton then
  450. Data.CurrentCategoryButton.BackgroundColor3 = buttonColor
  451. Data.CurrentCategoryButton.TextColor3 = buttonTextColor
  452. Data.CurrentCategoryButton.AutoButtonColor = true
  453. Data.CurrentCategoryButton.Style = "RobloxButton"
  454. end
  455. end
  456. selectCategoryPage(category, 0)
  457.  
  458. Data.CurrentCategoryButton = button
  459. Data.CurrentCategoryButton.BackgroundColor3 = selectedButtonColor
  460. Data.CurrentCategoryButton.TextColor3 = selectedButtonTextColor
  461. Data.CurrentCategoryButton.AutoButtonColor = false
  462. Data.CurrentCategoryButton.Style = "RobloxButtonDefault"
  463. end
  464.  
  465. function processCategory(sets, setPanel)
  466. local setButtons = {}
  467. for index, object in pairs(sets) do
  468. --for key, value in pairs(object) do
  469. -- print("key=" .. key .. ", value=" .. value)
  470. --end
  471. setButtons[index] = buildSetButton(object.Name, object.CategoryId, object.ImageAssetId, index, #sets)
  472. setButtons[index].Parent = setPanel
  473. end
  474. return setButtons
  475. end
  476.  
  477. function buildMainGui(root, userId)
  478. Window.Main = {}
  479. Data.Main = {}
  480. Data.Category = {}
  481.  
  482. local mainFrame = Instance.new("Frame")
  483. mainFrame.Name = "InsertMainDialog"
  484. mainFrame.Position = UDim2.new(0.0, 0, 0.25, 0)
  485. mainFrame.Size = UDim2.new(0.75, 0, 0.75, 0)
  486. mainFrame.Transparency = 1.0
  487. mainFrame.Active = true
  488. mainFrame.Parent = root
  489. Window.Main.Frame = mainFrame
  490.  
  491. local setTab = Instance.new("Frame")
  492. setTab.Position = UDim2.new(0.0, 0, 0.0, 0)
  493. setTab.Size = UDim2.new(0.15, 0, 1.0, 0)
  494. setTab.BackgroundTransparency = 1.0
  495. setTab.Name = "SetTab"
  496. setTab.Parent = mainFrame
  497.  
  498. local setPanel = Instance.new("Frame")
  499. setPanel.Position = UDim2.new(0.0, 0, 0.0, 0)
  500. setPanel.Size = UDim2.new(1.0, 0, 1.0, 0)
  501. setPanel.BackgroundTransparency = 1.0
  502. setPanel.Name = "SetPanel"
  503. setPanel.Parent = setTab
  504.  
  505. local setFiller = Instance.new("Frame")
  506. setFiller.Name = "SetFiller"
  507. setFiller.Size = UDim2.new(0.0, 0, 0.0, 0)
  508. setFiller.Position = UDim2.new(0.0, 0, 0.0, 0)
  509. setFiller.BackgroundColor3 = frameColor
  510. setFiller.BackgroundTransparency = transparency*.5
  511. setFiller.Parent = setTab
  512.  
  513. local previousSetButton = Instance.new("TextButton")
  514. previousSetButton.Name = "PreviousSetButton"
  515. previousSetButton.Style = "RobloxButton"
  516. previousSetButton.Size = UDim2.new(1.0, 0, 0, height)
  517. previousSetButton.Position = UDim2.new(0.0, 0, 0.0, 0)
  518. previousSetButton.BackgroundColor3 = buttonColor
  519. previousSetButton.TextColor3 = buttonTextColor
  520. previousSetButton.BackgroundTransparency = transparency
  521. previousSetButton.Text = "..."
  522. previousSetButton.MouseButton1Click:connect(previousCategoryPage)
  523. previousSetButton.Parent = setTab
  524. previousSetButton.Visible = false
  525. Window.Main.PreviousSetButton = previousSetButton
  526.  
  527. local nextSetButton = Instance.new("TextButton")
  528. nextSetButton.Style = "RobloxButton"
  529. nextSetButton.Name = "NextSetButton"
  530. nextSetButton.Size = UDim2.new(1.0, 0, 0.0, height)
  531. nextSetButton.Position = UDim2.new(0.0, 0, 1.0, -height)
  532. nextSetButton.BackgroundColor3 = buttonColor
  533. nextSetButton.TextColor3 = buttonTextColor
  534. nextSetButton.BackgroundTransparency = transparency
  535. nextSetButton.Text = "..."
  536. nextSetButton.MouseButton1Click:connect(nextCategoryPage)
  537. nextSetButton.Parent = setTab
  538. nextSetButton.Visible = false
  539. Window.Main.NextSetButton = nextSetButton
  540.  
  541. local insertTab = Instance.new("Frame")
  542. insertTab.Name = "InsertTab"
  543. insertTab.Position = UDim2.new(0.15, 0, 0.0, 0)
  544. insertTab.Size = UDim2.new(0.85, 0, 1.0, 0)
  545. insertTab.BackgroundTransparency = 1.0
  546. insertTab.Parent = mainFrame
  547.  
  548. Data.BaseCategoryButtons = processCategory(game:GetService("InsertService"):GetBaseCategories(), setPanel)
  549. local userData = game:GetService("InsertService"):GetUserCategories(userId)
  550. if userData then
  551. Data.UserCategoryButtons = processCategory(userData, setPanel)
  552.  
  553. local userCategoryButton = Instance.new("TextButton")
  554. userCategoryButton.Style = "RobloxButton"
  555. userCategoryButton.Font = "ArialBold"
  556. userCategoryButton.FontSize = "Size14"
  557. userCategoryButton.Name = "UserCategoryButton"
  558. userCategoryButton.Size = UDim2.new(0.25, 0, 0, height)
  559. userCategoryButton.Position = UDim2.new(0.25, 0, 0.0, -height)
  560. userCategoryButton.BackgroundColor3 = buttonColor
  561. userCategoryButton.TextColor3 = buttonTextColor
  562. userCategoryButton.BackgroundTransparency = transparency*.5
  563. userCategoryButton.Text = "User Sets"
  564. userCategoryButton.MouseButton1Click:connect(function() selectCategory(userCategoryButton, Data.UserCategoryButtons) end)
  565. userCategoryButton.Parent = insertTab
  566. end
  567. --Data.UserCategoryButtons = processCategory(game:GetService("InsertService"):GetBaseCategories(), setPanel)
  568.  
  569. local baseCategoryButton = Instance.new("TextButton")
  570. baseCategoryButton.Style = "RobloxButton"
  571. baseCategoryButton.Font = "ArialBold"
  572. baseCategoryButton.FontSize = "Size14"
  573. baseCategoryButton.Name = "RobloxCategoryButton"
  574. baseCategoryButton.Size = UDim2.new(0.25, 0, 0, height)
  575. baseCategoryButton.Position = UDim2.new(0.0, 0, 0.0, -height)
  576. baseCategoryButton.BackgroundColor3 = buttonColor
  577. baseCategoryButton.TextColor3 = buttonTextColor
  578. baseCategoryButton.BackgroundTransparency = transparency *.5
  579. baseCategoryButton.Text = "Roblox Sets"
  580. baseCategoryButton.MouseButton1Click:connect(function() selectCategory(baseCategoryButton, Data.BaseCategoryButtons) end)
  581. baseCategoryButton.Parent = insertTab
  582.  
  583. local titleFrame = Instance.new("TextLabel")
  584. titleFrame.Name = "Title"
  585. titleFrame.Font = "ArialBold"
  586. titleFrame.FontSize = "Size14"
  587. titleFrame.Position = UDim2.new(0.0, 0, 0.0, 0)
  588. titleFrame.Size = UDim2.new(1.0, 0, 0.0, height)
  589. titleFrame.TextWrap = true
  590. titleFrame.BackgroundColor3 = titleColor
  591. titleFrame.TextColor3 = titleTextColor
  592. titleFrame.BackgroundTransparency = .1
  593. titleFrame.Text = "Set Foo"
  594. titleFrame.Parent = insertTab
  595. Window.Main.Title = titleFrame
  596.  
  597. local minimizeButton = Instance.new("ImageButton")
  598. minimizeButton.Name = "Minimize"
  599. minimizeButton.Position = UDim2.new(1.0, -height + 1, 0.0, 1)
  600. minimizeButton.Size = UDim2.new(0.0, height-2, 0.0, height-2)
  601. minimizeButton.Image = BaseUrl .. "asset?id=20889725"
  602. minimizeButton.MouseButton1Click:connect(minimize)
  603. minimizeButton.Parent = titleFrame
  604.  
  605. local insertPanel = Instance.new("Frame")
  606. insertPanel.Name = "InsertPanel"
  607. insertPanel.Position = UDim2.new(0.0, 0, 0.0, height)
  608. insertPanel.Size = UDim2.new(1.0, 0, 1.0, -2*height)
  609. insertPanel.BackgroundColor3 = frameColor
  610. insertPanel.BackgroundTransparency = transparency
  611. insertPanel.Parent = insertTab
  612.  
  613. local footerPanel = Instance.new("Frame")
  614. footerPanel.Name = "Footer"
  615. footerPanel.Size = UDim2.new(1.0, 0, 0, height)
  616. footerPanel.Position = UDim2.new(0.0, 0, 1.0, -height)
  617. footerPanel.BackgroundTransparency = transparency
  618. footerPanel.BackgroundColor3 = frameColor
  619. footerPanel.Parent = insertTab
  620.  
  621. local rolloverText = Instance.new("TextLabel")
  622. rolloverText.Name = "RolloverText"
  623. rolloverText.Size = UDim2.new(0.8, 0, 1.0, 0)
  624. rolloverText.Position = UDim2.new(0.1, 0, 0.0, 0)
  625. rolloverText.TextColor3 = frameTextColor
  626. rolloverText.BackgroundColor3 = frameColor
  627. rolloverText.BackgroundTransparency = transparency
  628. rolloverText.Text = ""
  629. rolloverText.TextWrap = true
  630. rolloverText.Parent = footerPanel
  631. Window.Main.RolloverText = rolloverText
  632.  
  633. local previousButton = Instance.new("TextButton")
  634. previousButton.Style = "RobloxButton"
  635. previousButton.Font = "ArialBold"
  636. previousButton.FontSize = "Size14"
  637. previousButton.Name = "PreviousPageButton"
  638. previousButton.Size = UDim2.new(0.1, 0, 1.0, 0)
  639. previousButton.Position = UDim2.new(0.0, 0, 0.0, 0)
  640. previousButton.BackgroundColor3 = buttonColor
  641. previousButton.TextColor3 = buttonTextColor
  642. previousButton.BackgroundTransparency = transparency
  643. previousButton.Text = "<--"
  644. previousButton.MouseButton1Click:connect(previousSetPage)
  645. previousButton.Parent = footerPanel
  646. previousButton.Visible = false
  647. Window.Main.PreviousPageButton = previousButton
  648.  
  649. local nextButton = Instance.new("TextButton")
  650. nextButton.Name = "NextPageButton"
  651. nextButton.Style = "RobloxButton"
  652. nextButton.Font = "ArialBold"
  653. nextButton.FontSize = "Size14"
  654. nextButton.Size = UDim2.new(0.1, 0, 1.0, 0)
  655. nextButton.Position = UDim2.new(0.9, 0, 0.0, 0)
  656. nextButton.BackgroundColor3 = buttonColor
  657. nextButton.TextColor3 = buttonTextColor
  658. nextButton.BackgroundTransparency = transparency
  659. nextButton.Text = "-->"
  660. nextButton.MouseButton1Click:connect(nextSetPage)
  661. nextButton.Parent = footerPanel
  662. nextButton.Visible = false
  663. Window.Main.NextPageButton = nextButton
  664.  
  665. local insertButtons = {}
  666. for y = 1, InsertRows do
  667. for x = 1, InsertColumns do
  668. insertButtons[x + (y - 1) * InsertColumns] = buildInsertButton(UDim2.new(.125*(x-1), 2, 0.25*(y-1), 2), UDim2.new(.125, -4, .25, -4))
  669. insertButtons[x + (y - 1) * InsertColumns].Parent = insertPanel
  670. end
  671. end
  672. Data.InsertButtons = insertButtons
  673. Data.Main.InsertRows = InsertRows
  674. Data.Main.InsertColumns = InsertColumns
  675.  
  676. selectCategory(baseCategoryButton, Data.BaseCategoryButtons)
  677. end
  678.  
  679. function layoutInsertButtons(guiMain)
  680. local size = guiMain.AbsoluteSize
  681.  
  682. local frameSize = 0.75 * size
  683. local frameSizeUsed = Vector2.new(0, height*2)
  684.  
  685. --We want 15% or 100 pixels, which ever is smaller
  686. if frameSize.x * .15 < 100 then
  687. local oldSize = Window.Main.Frame.SetTab.Size
  688. Window.Main.Frame.SetTab.Size = UDim2.new(0.0, 100, oldSize.Y.Scale, oldSize.Y.Offset)
  689. Window.Main.Frame.InsertTab.Position = UDim2.new(0.0, 100, 0.0, 0)
  690. frameSizeUsed = Vector2.new(frameSizeUsed.x + 100, frameSizeUsed.y)
  691. else
  692. local oldSize = Window.Main.Frame.SetTab.Size
  693. Window.Main.Frame.SetTab.Size = UDim2.new(0.15, 0, oldSize.Y.Scale, oldSize.Y.Offset)
  694. Window.Main.Frame.InsertTab.Position = UDim2.new(0.15, 0, 0.0, 0)
  695. frameSizeUsed = Vector2.new(frameSizeUsed.x + .15*frameSize.x, frameSizeUsed.y)
  696. end
  697.  
  698. --Decide how many buttons we can fit, and what size to make the insert buttons
  699. --2 sizes of insert buttons, 50x50 and 100x100
  700.  
  701. local buttonSize = 110
  702. while buttonSize > 70 and math.floor((frameSize - frameSizeUsed).x/buttonSize) * math.floor((frameSize - frameSizeUsed).y/buttonSize) < 32 do
  703. buttonSize = buttonSize - 10
  704. end
  705.  
  706. Data.Main.InsertColumns = math.min(math.max(1, math.floor((frameSize - frameSizeUsed).x/buttonSize)), InsertColumns)
  707. Data.Main.InsertRows = math.min(math.max(1, math.floor((frameSize - frameSizeUsed).y/buttonSize)), InsertRows)
  708.  
  709. for index, button in pairs(Data.InsertButtons) do
  710. if index <= Data.Main.InsertRows * Data.Main.InsertColumns then
  711. button.Visible = true
  712. button.Size = UDim2.new(0, buttonSize-4, 0, buttonSize-4)
  713. button.Position = UDim2.new(0, buttonSize * ((index-1)%Data.Main.InsertColumns) + 2 + 2,
  714. 0, buttonSize * math.floor((index-1)/Data.Main.InsertColumns) + 2 + 2)
  715. else
  716. button.Visible = false
  717. end
  718. end
  719. Window.Main.Frame.InsertTab.Size = UDim2.new(0.0, buttonSize * Data.Main.InsertColumns + 4, 0.0, buttonSize * Data.Main.InsertRows + height*2 + 4)
  720.  
  721. if Data.Category[Data.CurrentCategory].Index == nil then
  722. setSetIndex(0)
  723. else
  724. setSetIndex(Data.Category[Data.CurrentCategory].Index)
  725. end
  726.  
  727. local finalFrameHeight = frameSizeUsed.y + Data.Main.InsertRows*buttonSize + 4
  728. Window.Main.Frame.Size = UDim2.new(0, frameSizeUsed.x + Data.Main.InsertColumns*buttonSize + 4, 0, finalFrameHeight)
  729. Window.Main.Frame.Position = UDim2.new(0.0, 0, 1.0, -Window.Main.Frame.Size.Y.Offset)
  730.  
  731. if Data.Category[Data.CurrentCategory].SetIndex == nil then
  732. layoutSetButtons(finalFrameHeight, 1)
  733. else
  734. layoutSetButtons(finalFrameHeight, Data.Category[Data.CurrentCategory].SetIndex)
  735. end
  736. end
  737.  
  738. function layoutSetButtons(frameHeight, setIndex)
  739. Data.Main.FrameHeight = frameHeight
  740. Data.Main.InsertSets = math.floor(frameHeight / (height*2))
  741. if #Data.CurrentCategory > Data.Main.InsertSets then
  742. --Steal one entry since we have two many things
  743. Data.Main.InsertSets = Data.Main.InsertSets - 1
  744. end
  745.  
  746. print("Layout Set Buttons index=" .. setIndex .. ", InsertSets="..Data.Main.InsertSets)
  747.  
  748. setCategoryIndex(setIndex)
  749. end
  750.  
  751.  
  752. function insertComplete()
  753. Window.Loading.Frame.Visible = false
  754. Window.Stamp.Frame.Visible = false
  755. Window.Main.Frame.Visible = true
  756. end
  757.  
  758. function UnlockInstances(object)
  759. if object:IsA("BasePart") then
  760. object.Locked = false
  761. end
  762. for index,child in pairs(object:GetChildren()) do
  763. UnlockInstances(child)
  764. end
  765. end
  766.  
  767. function beginInsertDecal(decal)
  768.  
  769. Data.Stamp.DecalSelection = Instance.new("SurfaceSelection")
  770. Data.Stamp.DecalSelection.Color = BrickColor.new("Bright orange")
  771. Data.Stamp.DecalSelection.archivable = false
  772. Data.Stamp.DecalSelection.Parent = getPlayer().PlayerGui
  773.  
  774. --Save the decal in our Lua code for later use
  775. Data.Stamp.Decal = decal
  776. Data.Stamp.Decal.Parent = nil
  777. end
  778.  
  779. function beginInsertAsset(assetName, assetId, image, stampMode)
  780. --Copy over details into dialog window
  781. Window.Loading.AssetThumbLabel.Image = image
  782. Window.Loading.AssetNameLabel.Text = assetName
  783.  
  784. Window.Stamp.AssetThumbLabel.Image = image
  785. Window.Stamp.AssetNameLabel.Text = assetName
  786. Data.Stamp.StampMode = stampMode
  787.  
  788. --Hide the main window
  789. Window.Main.Frame.Visible = false
  790. --Show the dialog window
  791. Window.Loading.Frame.Visible = true
  792. Data.Loading.Cancelled = false
  793.  
  794. --This call will cause a "wait" until the data comes back
  795. local root
  796. if useAssetVersionId then
  797. root = game:GetService("InsertService"):LoadAssetVersion(assetId)
  798. else
  799. root = game:GetService("InsertService"):LoadAsset(assetId)
  800. end
  801.  
  802. if Data.Loading.Cancelled then
  803. --The user got bored and wandered off
  804.  
  805. --Just delete the model from the world... a shame we loaded it when they got bored
  806. root:Remove()
  807. else
  808. Window.Loading.Frame.Visible = false
  809.  
  810. local instances = root:GetChildren()
  811. if #instances == 0 then
  812. root:Remove()
  813. insertComplete()
  814. return
  815. end
  816.  
  817. --Unlock all parts that are inserted, to make sure they are editable
  818. UnlockInstances(root)
  819.  
  820. --Continue the insert process
  821. root.Name = "InsertedObject" .. assetId
  822.  
  823. --Examine the contents and decide what it looks like
  824. for pos, instance in pairs(instances) do
  825. --Single instance objects might be treated special, decals/skyboxes
  826. if instance:IsA("Decal") then
  827. --Current system here stops after finding one Decal (and gives you Decal tool)
  828. --We should do the same (probably)
  829. beginInsertDecal(instance)
  830. root:Remove()
  831.  
  832. Window.Stamp.Frame.Visible = true
  833. return
  834. elseif instance:IsA("Team") then
  835. instance.Parent = game:GetService("Teams")
  836. elseif instance:IsA("SpawnLocation") then
  837.  
  838. elseif instance:IsA("HopperBin") then
  839. -- Must go into the starterPack, prompt user?
  840. elseif instance:IsA("Tool") then
  841. -- Ask them if it should go in StarterPack?
  842. elseif instance:IsA("Sky") then
  843. local lightingService = game:GetService("Lighting")
  844. for index,child in pairs(lightingService:GetChildren()) do
  845. if child:IsA("Sky") then
  846. child:Remove();
  847. end
  848. end
  849. instance.Parent = lightingService
  850. return
  851. else
  852.  
  853. end
  854. end
  855.  
  856. if #root:GetChildren() == 0 then
  857. root:Remove()
  858. insertComplete()
  859. return
  860. end
  861.  
  862. Window.Stamp.Frame.Visible = true
  863. Data.Stamp.Model = root
  864. end
  865. end
  866.  
  867. function cancelAssetLoad()
  868. Data.Loading.Cancelled = true
  869. insertComplete()
  870. end
  871.  
  872. function buildLoadingDialogGui(root)
  873. Window.Loading = {}
  874. Data.Loading = {}
  875.  
  876. local dialogFrame = Instance.new("Frame")
  877. dialogFrame.Name = "InsertLoadingDialog"
  878. dialogFrame.Style = "ChatRed"
  879. dialogFrame.Size = UDim2.new(0.0, height*10, 0, height*5)
  880. dialogFrame.Position = UDim2.new(0, 0, 1, -140)
  881. dialogFrame.BackgroundColor3 = frameColor
  882. dialogFrame.Active = true
  883. dialogFrame.Parent = root
  884. dialogFrame.Visible = false
  885. Window.Loading.Frame = dialogFrame
  886.  
  887. local assetThumb = Instance.new("ImageLabel")
  888. assetThumb.Position = UDim2.new(0.0, 2, 0.0, 2)
  889. assetThumb.Size = UDim2.new(0.5, -4, 1.0, -4)
  890. assetThumb.Parent = dialogFrame
  891. Window.Loading.AssetThumbLabel = assetThumb
  892.  
  893. local descriptionFrame = Instance.new("Frame")
  894. descriptionFrame.Name = "Description"
  895. descriptionFrame.Size = UDim2.new(0.5, 0, 1.0, 0)
  896. descriptionFrame.Position = UDim2.new(0.5, 0, 0.0, 0)
  897. descriptionFrame.Transparency = 1
  898. descriptionFrame.Parent = dialogFrame
  899.  
  900. local label = Instance.new("TextLabel")
  901. label.Text = "Loading..."
  902. label.Position = UDim2.new(0.5, 0, 0, 0);
  903. label.Size = UDim2.new(0.0, 0, 0.0, height)
  904. label.BorderSizePixel = 0
  905. label.TextColor3 = frameTextColor
  906. label.Parent = descriptionFrame
  907.  
  908. local assetLabel = Instance.new("TextLabel")
  909. assetLabel.Text = "Your Asset Here"
  910. assetLabel.Position = UDim2.new(0.0, 0, 0.0, height)
  911. assetLabel.Size = UDim2.new(1.0, 0, 1.0, -2*height)
  912. assetLabel.BorderSizePixel = 0
  913. assetLabel.BackgroundTransparency = 1.0
  914. assetLabel.Parent = descriptionFrame
  915. assetLabel.TextColor3 = frameTextColor
  916. assetLabel.TextWrap = true
  917. Window.Loading.AssetNameLabel = assetLabel
  918.  
  919. local cancelButton = Instance.new("TextButton")
  920. cancelButton.Name = "PreviousPageButton"
  921. cancelButton.Style = "RobloxButtonDefault"
  922. cancelButton.Size = UDim2.new(0, height*3, 0, height)
  923. cancelButton.Position = UDim2.new(0.5, -height*1.5, 1.0, -height*1.2)
  924. cancelButton.BackgroundColor3 = buttonColor
  925. cancelButton.TextColor3 = buttonTextColor
  926. cancelButton.Text = "Cancel"
  927. cancelButton.MouseButton1Click:connect(cancelAssetLoad)
  928. cancelButton.Parent = descriptionFrame
  929. end
  930.  
  931.  
  932.  
  933. function cancelAssetPlacement()
  934. Data.Stamp.Cancelled = true
  935. Data.Stamp.Dragger = nil
  936. if Data.Stamp.Model then
  937. Data.Stamp.Model:Remove()
  938. Data.Stamp.Model = nil
  939. end
  940. if Data.Stamp.CurrentParts then
  941. for index, object in pairs(Data.Stamp.CurrentParts) do
  942. object:Remove()
  943. end
  944. Data.Stamp.CurrentParts = nil
  945. end
  946.  
  947. if Data.Stamp.DecalSelection then
  948. Data.Stamp.DecalSelection:Remove()
  949. Data.Stamp.DecalSelection = nil
  950. end
  951. if Data.Stamp.Decal then
  952. Data.Stamp.Decal:Remove()
  953. Data.Stamp.Decal = nil
  954. end
  955.  
  956. if Mouse then
  957. Mouse.Icon ="rbxasset://textures\\ArrowCursor.png"
  958. end
  959. insertComplete()
  960. end
  961.  
  962. function onInsertKeyDown(key)
  963. if Data.Stamp.Dragger then
  964. if key == 'R' or key == 'r' then
  965. Data.Stamp.Dragger:AxisRotate(Enum.Axis.Y)
  966. elseif key == 'T' or key == 't' then
  967. Data.Stamp.Dragger:AxisRotate(Enum.Axis.Z)
  968. end
  969. end
  970. if key == '' then
  971. minimize()
  972. end
  973. end
  974.  
  975.  
  976. function canSelectObject(part)
  977. return part and not (part.Locked) and part:IsA("BasePart") and (part.Position - Tool.Parent.Head.Position).Magnitude < 60
  978. end
  979.  
  980. function setSelectionSurface(part, surface)
  981. if Data.Stamp.DecalSelection.Adornee == part and Data.Stamp.DecalSelection.TargetSurface == surface then
  982. return
  983. end
  984. unsetSelectionSurface()
  985. Data.Stamp.DecalSelection.Adornee = part
  986. Data.Stamp.DecalSelection.TargetSurface = surface
  987. --selectionLasso.Part = part
  988.  
  989. local decalFound = false
  990. for index,child in pairs(part:GetChildren()) do
  991. if child:IsA("Decal") and child.Face == surface then
  992. decalFound = true
  993. break
  994. end
  995. end
  996.  
  997. if not(decalFound) then
  998. Data.Stamp.Decal.Parent = part
  999. Data.Stamp.Decal.Face = surface
  1000. end
  1001. end
  1002.  
  1003. function unsetSelectionSurface()
  1004. Data.Stamp.DecalSelection.Adornee = nil
  1005. --selectionLasso.Part = nil
  1006. Data.Stamp.Decal.Parent = nil
  1007. end
  1008.  
  1009. function onInsertMouseMove()
  1010. if Data.Stamp.MovingLock then
  1011. return
  1012. end
  1013.  
  1014. local newCursor = "rbxasset://textures\\ArrowCursor.png"
  1015. Data.Stamp.MovingLock = true
  1016. if Data.Stamp.Decal then
  1017. local part = Mouse.Target
  1018. if canSelectObject(part) then
  1019. setSelectionSurface(part, Mouse.TargetSurface)
  1020. else
  1021. unsetSelectionSurface()
  1022. newCursor = BaseUrl .. "asset?id=20715642"
  1023. end
  1024. elseif Data.Stamp.Dragger == nil then
  1025. if Data.Stamp.Model ~= nil then
  1026. Mouse.Icon ="rbxasset://textures//GrabRotateCursor.png"
  1027. setupDraggableClone()
  1028. end
  1029. else
  1030. Data.Stamp.Dragger:MouseMove(Mouse.UnitRay)
  1031. end
  1032. Mouse.Icon = newCursor
  1033.  
  1034. Data.Stamp.MovingLock = false
  1035. end
  1036.  
  1037. function onInsertMouseButton1Down()
  1038. if Data.Stamp.Dragger or Data.Stamp.Decal then
  1039. Data.Stamp.MouseDown = true
  1040. end
  1041. end
  1042.  
  1043. function onInsertMouseButton1Up()
  1044. if Data.Stamp.MouseDown then
  1045. Data.Stamp.MouseDown = false
  1046. if Data.Stamp.Decal then
  1047. local part = Mouse.Target
  1048. if canSelectObject(part) and Instance.Lock(part) then
  1049. local surface = Mouse.TargetSurface
  1050. for index,child in pairs(part:GetChildren()) do
  1051. if child:IsA("Decal") and child.Face == surface then
  1052. child:Remove()
  1053. end
  1054. end
  1055.  
  1056. local newDecal = Data.Stamp.Decal:Clone()
  1057. newDecal.Face = surface
  1058. newDecal.Parent = part
  1059. Instance.Unlock(part)
  1060.  
  1061. if Data.Stamp.StampMode then
  1062. else
  1063. Instance.Unlock(part)
  1064. cancelAssetPlacement()
  1065. end
  1066. end
  1067. elseif Data.Stamp.Dragger then
  1068. --Place the object where the mouse is currently positioned
  1069. Data.Stamp.Dragger:MouseUp()
  1070.  
  1071. --Fix the transparency of all the parts
  1072. for part, transparency in pairs(Data.Stamp.TransparencyTable) do
  1073. part.Transparency = transparency
  1074. end
  1075. Data.Stamp.TransparencyTable = nil
  1076.  
  1077. --Re-enable the scripts
  1078. for index,script in pairs(Data.Stamp.DisabledScripts) do
  1079. script.Disabled = false
  1080. end
  1081. --Now that they are all marked enabled, reinsert them into the world so they start running
  1082. for index,script in pairs(Data.Stamp.DisabledScripts) do
  1083. local oldParent = script.Parent
  1084. script.Parent = nil
  1085. script:Clone().Parent = oldParent
  1086. end
  1087. Data.Stamp.DisabledScripts = nil
  1088.  
  1089. Data.Stamp.Dragger = nil
  1090. Data.Stamp.CurrentParts = nil
  1091.  
  1092. if Data.Stamp.StampMode then
  1093. --Now set up a new instance of the object to allow a second copy to be stamped down
  1094. setupDraggableClone()
  1095. else
  1096. cancelAssetPlacement()
  1097. end
  1098. end
  1099. end
  1100. end
  1101.  
  1102.  
  1103. function collectParts(object, baseParts, scripts)
  1104. if object:IsA("BasePart") then
  1105. baseParts[#baseParts+1] = object
  1106. elseif object:IsA("Script") then
  1107. scripts[#scripts+1] = object
  1108. end
  1109.  
  1110. for index,child in pairs(object:GetChildren()) do
  1111. collectParts(child, baseParts, scripts)
  1112. end
  1113. end
  1114.  
  1115.  
  1116.  
  1117. function setupDraggableClone()
  1118. local clone = Data.Stamp.Model:Clone()
  1119. local scripts = {}
  1120. local parts = {}
  1121.  
  1122. collectParts(clone, parts, scripts)
  1123.  
  1124. if #parts > 0 then
  1125. Data.Stamp.DisabledScripts = {}
  1126. Data.Stamp.TransparencyTable = {}
  1127.  
  1128. for index,script in pairs(scripts) do
  1129. if not(script.Disabled) then
  1130. script.Disabled = true
  1131. Data.Stamp.DisabledScripts[#Data.Stamp.DisabledScripts +1] = script
  1132. end
  1133. end
  1134. for index, part in pairs(parts) do
  1135. Data.Stamp.TransparencyTable[part] = part.Transparency
  1136. part.Transparency = 0.5
  1137. end
  1138.  
  1139. game:GetService("InsertService"):Insert(clone)
  1140.  
  1141. Data.Stamp.CurrentParts = clone:GetChildren();
  1142. for index, object in pairs(Data.Stamp.CurrentParts) do
  1143. object.Parent = clone.Parent
  1144. end
  1145. clone:Remove();
  1146.  
  1147. Data.Stamp.Dragger = Instance.new("Dragger")
  1148. --Begin a movement by faking a MouseDown signal
  1149. Data.Stamp.Dragger:MouseDown(parts[1], Vector3.new(0,0,0), parts)
  1150. Data.Stamp.Dragger:MouseMove(Mouse.UnitRay)
  1151. else
  1152. --Nothing draggable in the Model
  1153. Data.Stamp.Model:Remove()
  1154. Data.Stamp.Model = nil
  1155. Data.Stamp.TransparencyTable = nil
  1156. Data.Stamp.DisabledScripts = nil
  1157. end
  1158. end
  1159. function buildStampDialogGui(root)
  1160. Window.Stamp = {}
  1161. Data.Stamp = {}
  1162.  
  1163. local dialogFrame = Instance.new("Frame")
  1164. dialogFrame.Name = "InsertStampDialog"
  1165. dialogFrame.Style = "ChatGreen"
  1166. dialogFrame.Size = UDim2.new(0.0, height*10, 0, height*5)
  1167. dialogFrame.Position = UDim2.new(0.0, 0, 1.0, -140)
  1168. dialogFrame.BackgroundColor3 = frameColor
  1169. dialogFrame.Active = true
  1170. dialogFrame.Parent = root
  1171. dialogFrame.Visible = false
  1172. Window.Stamp.Frame = dialogFrame
  1173.  
  1174. local assetThumb = Instance.new("ImageLabel")
  1175. assetThumb.Position = UDim2.new(0.0, 2, 0.0, 2)
  1176. assetThumb.Size = UDim2.new(0.5, -4, 1.0, -4)
  1177. assetThumb.Parent = dialogFrame
  1178. Window.Stamp.AssetThumbLabel = assetThumb
  1179.  
  1180. local descriptionFrame = Instance.new("Frame")
  1181. descriptionFrame.Name = "Description"
  1182. descriptionFrame.Size = UDim2.new(0.5, 0, 1.0, 0)
  1183. descriptionFrame.Position = UDim2.new(0.5, 0, 0.0, 0)
  1184. descriptionFrame.Transparency = 1
  1185. descriptionFrame.Parent = dialogFrame
  1186.  
  1187. local assetLabel = Instance.new("TextLabel")
  1188. assetLabel.Text = "Your Asset Here"
  1189. assetLabel.Position = UDim2.new(0.0, 0, 0.0, 0)
  1190. assetLabel.Size = UDim2.new(1.0, 0, 1.0, -height)
  1191. assetLabel.BorderSizePixel = 0
  1192. assetLabel.BackgroundTransparency = 1.0
  1193. assetLabel.Parent = descriptionFrame
  1194. assetLabel.TextColor3 = frameTextColor
  1195. assetLabel.TextWrap = true
  1196. Window.Stamp.AssetNameLabel = assetLabel
  1197.  
  1198. local cancelButton = Instance.new("TextButton")
  1199. cancelButton.Name = "CancelButton"
  1200. cancelButton.Style = "RobloxButtonDefault"
  1201. cancelButton.Size = UDim2.new(0, height*4.5, 0, height)
  1202. cancelButton.Position = UDim2.new(0.5, -height*2.25, 1.0, -height*1.2)
  1203. cancelButton.BackgroundColor3 = buttonColor
  1204. cancelButton.TextColor3 = buttonTextColor
  1205. cancelButton.Text = "Back to Toolbox"
  1206. cancelButton.MouseButton1Click:connect(cancelAssetPlacement)
  1207. cancelButton.Parent = descriptionFrame
  1208.  
  1209. Data.Stamp.MovingLock = false
  1210. end
  1211.  
  1212. function buildInitialLoadScreen(root)
  1213. local dialogFrame = Instance.new("Frame")
  1214. dialogFrame.Name = "InsertLoadingScreen"
  1215. dialogFrame.Size = UDim2.new(0.0, height*10, 0, height*5)
  1216. dialogFrame.Position = UDim2.new(0.5, -height*5, 0.5, -height*2.5)
  1217. dialogFrame.BackgroundColor3 = frameColor
  1218. dialogFrame.Active = true
  1219. dialogFrame.Visible = true
  1220. dialogFrame.Parent = root
  1221.  
  1222. local label = Instance.new("TextLabel")
  1223. label.Text = "Loading"
  1224. label.Font = "ArialBold"
  1225. label.FontSize = "Size14"
  1226. label.Position = UDim2.new(0.0, 0, 0, 0)
  1227. label.Size = UDim2.new(1.0, 0, 0.0, height)
  1228. label.BorderSizePixel = 1
  1229. label.TextColor3 = titleTextColor
  1230. label.BackgroundColor3 = titleColor
  1231. label.Parent = dialogFrame
  1232.  
  1233. local assetLabel = Instance.new("TextLabel")
  1234. assetLabel.Text = "Please Wait"
  1235. assetLabel.Font = "ArialBold"
  1236. assetLabel.FontSize = "Size14"
  1237. assetLabel.Position = UDim2.new(0.0, 0, 0.0, height)
  1238. assetLabel.Size = UDim2.new(1.0, 0, 1.0, -2*height)
  1239. assetLabel.BorderSizePixel = 1
  1240. assetLabel.BackgroundTransparency = 1.0
  1241. assetLabel.TextColor3 = frameTextColor
  1242. assetLabel.TextWrap = true
  1243. assetLabel.Parent = dialogFrame
  1244. end
  1245.  
  1246. function buildMinimizedGui(root)
  1247. Window.Minimized = {}
  1248. Data.Minimized = {}
  1249. local minimizeButton = Instance.new("TextButton")
  1250. minimizeButton.Name = "MinimizeButton"
  1251. minimizeButton.Size = UDim2.new(0, height*4.5, 0, height)
  1252. minimizeButton.Position = UDim2.new(0.0, 0, 1.0, -height)
  1253. minimizeButton.BackgroundColor3 = buttonColor
  1254. minimizeButton.TextColor3 = buttonTextColor
  1255. minimizeButton.Text = "Toolbox"
  1256. minimizeButton.MouseButton1Click:connect(function() Window.Minimized.Frame.Visible = false Window.Main.Frame.Visible = true end)
  1257. minimizeButton.Visible = false
  1258. minimizeButton.Parent = root
  1259.  
  1260. Window.Minimized.Frame = minimizeButton
  1261. end
  1262.  
  1263.  
  1264. local CancelDuringLoad
  1265. local LoadScreen
  1266. function onEquippedLocal(mouse)
  1267. Tool.TextureId = "rbxasset://icons/insert_sel.png"
  1268.  
  1269. Mouse = mouse
  1270. if Tool.SavedState.Value and Tool.PlayerOwner.Value == getPlayer() and Data and Data.FullyLoaded then
  1271. guiMain = Tool.SavedState.Value
  1272. guiMain.Parent = getPlayer().PlayerGui
  1273.  
  1274. Window.Stamp.Frame.Visible = false
  1275. Window.Minimized.Frame.Visible = false
  1276. Window.Loading.Frame.Visible = false
  1277. Window.Main.Frame.Visible = true
  1278.  
  1279. --Window = Tool.SavedState.Value.Window
  1280. --Data = Tool.SavedState.Value.Window
  1281. else
  1282. CancelDuringLoad = false
  1283.  
  1284. LoadScreen = Instance.new("ScreenGui")
  1285. LoadScreen.Name = "InsertToolLoading"
  1286. buildInitialLoadScreen(LoadScreen)
  1287. LoadScreen.Parent = getPlayer().PlayerGui
  1288.  
  1289. guiMain = Instance.new("ScreenGui")
  1290. guiMain.Name = "InsertToolboxMain"
  1291. Window = {}
  1292. Data = {}
  1293. Data.FullyLoaded = false
  1294.  
  1295. buildMainGui(guiMain, getPlayer().userId)
  1296. buildLoadingDialogGui(guiMain)
  1297. buildStampDialogGui(guiMain)
  1298. buildMinimizedGui(guiMain)
  1299.  
  1300. LoadScreen:Remove()
  1301. LoadScreen = nil
  1302.  
  1303. if not(CancelDuringLoad) then
  1304. guiMain.Changed:connect(function(property) if property == "AbsoluteSize" then layoutInsertButtons(guiMain) end end)
  1305. guiMain.Parent = getPlayer().PlayerGui
  1306.  
  1307. Tool.SavedState.Value = guiMain
  1308. Tool.PlayerOwner.Value = getPlayer()
  1309. end
  1310.  
  1311. Data.FullyLoaded = true
  1312. end
  1313.  
  1314. Mouse.Move:connect(onInsertMouseMove)
  1315. Mouse.Button1Down:connect(onInsertMouseButton1Down)
  1316. Mouse.Button1Up:connect(onInsertMouseButton1Up)
  1317. Mouse.KeyDown:connect(onInsertKeyDown)
  1318.  
  1319. end
  1320.  
  1321. function onUnequippedLocal()
  1322. Tool.TextureId = origTexture
  1323.  
  1324. pcall(function()
  1325. cancelAssetPlacement()
  1326. cancelAssetLoad()
  1327. guiMain.Parent = nil
  1328. end)
  1329.  
  1330. CancelDuringLoad = true
  1331.  
  1332. if LoadScreen then
  1333. LoadScreen:Remove()
  1334. end
  1335. end
  1336.  
  1337. function onAncestryChanged(child,parent)
  1338. if Tool.PlayerOwner.Value and not Tool:IsDescendantOf(Tool.PlayerOwner.Value) and not Tool:IsDescendantOf(Tool.PlayerOwner.Value.Character) then
  1339. --Tool was dropped in some way, so we need to nuke our external state
  1340. Tool.SavedState.Value = nil
  1341. Tool.PlayerOwner.Value = nil
  1342. end
  1343.  
  1344. pcall(cancelAssetPlacement)
  1345. pcall(cancelAssetLoad)
  1346. end
  1347.  
  1348.  
  1349. Tool.Equipped:connect(onEquippedLocal)
  1350. Tool.Unequipped:connect(onUnequippedLocal)
  1351. Tool.AncestryChanged:connect(onAncestryChanged)
  1352. end))
  1353. ObjectValue2.Name = "SavedState"
  1354. ObjectValue2.Parent = Tool0
  1355. Part3.Name = "Handle"
  1356. Part3.Parent = Tool0
  1357. Part3.BrickColor = BrickColor.new("Dark stone grey")
  1358. Part3.Rotation = Vector3.new(-90, -0.00999999978, 90.0099945)
  1359. Part3.FormFactor = Enum.FormFactor.Plate
  1360. Part3.Size = Vector3.new(1, 0.800000012, 2)
  1361. Part3.CFrame = CFrame.new(1.59927368, 1.39172924, 1.49766541, -0.000197529793, -0.99999994, -9.59038734e-05, -1.80602074e-05, -9.58442688e-05, 0.99999994, -0.99999994, 0.000197589397, -1.80006027e-05)
  1362. Part3.BottomSurface = Enum.SurfaceType.Smooth
  1363. Part3.TopSurface = Enum.SurfaceType.Smooth
  1364. Part3.Color = Color3.new(0.388235, 0.372549, 0.384314)
  1365. Part3.Position = Vector3.new(1.59927368, 1.39172924, 1.49766541)
  1366. Part3.Orientation = Vector3.new(-89.9799957, -100.629997, -169.330002)
  1367. Part3.Color = Color3.new(0.388235, 0.372549, 0.384314)
  1368. SpecialMesh4.Parent = Part3
  1369. SpecialMesh4.MeshId = "http://www.roblox.com/asset/?id=18715644"
  1370. SpecialMesh4.Scale = Vector3.new(0.899999976, 0.899999976, 0.899999976)
  1371. SpecialMesh4.TextureId = "http://www.roblox.com/asset/?id=18715636"
  1372. SpecialMesh4.MeshType = Enum.MeshType.FileMesh
  1373. SpecialMesh4.Scale = Vector3.new(0.899999976, 0.899999976, 0.899999976)
  1374. Sound5.Parent = Part3
  1375. Sound5.SoundId = "http://www.roblox.com/asset/?id=18716629"
  1376. Sound6.Parent = Part3
  1377. Sound6.SoundId = "http://www.roblox.com/asset/?id=18716629"
  1378. Sound7.Parent = Part3
  1379. Sound7.SoundId = "http://www.roblox.com/asset/?id=18716629"
  1380. Sound8.Parent = Part3
  1381. Sound8.SoundId = "http://www.roblox.com/asset/?id=18716629"
  1382. Sound9.Parent = Part3
  1383. Sound9.SoundId = "http://www.roblox.com/asset/?id=18716629"
  1384. Sound10.Parent = Part3
  1385. Sound10.SoundId = "http://www.roblox.com/asset/?id=18716629"
  1386. ObjectValue11.Name = "PlayerOwner"
  1387. ObjectValue11.Parent = Tool0
  1388. for i,v in pairs(mas:GetChildren()) do
  1389. v.Parent = game:GetService("Players").LocalPlayer.Backpack
  1390. pcall(function() v:MakeJoints() end)
  1391. end
  1392. mas:Destroy()
  1393. for i,v in pairs(cors) do
  1394. spawn(function()
  1395. pcall(v)
  1396. end)
  1397. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement