lolita5432

insert tool hopefully work

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