lolita5432

iwididwfuaweifuwehyauifyaeywfoiueahgfawiufgeawuifyqewf

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