Advertisement
NicolasSilva321

Untitled

Mar 29th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.03 KB | None | 0 0
  1. --[[
  2. ===============================================================
  3. ===============] Box script by Mokiros [===================
  4. ==============] <Potato is Good> [==================
  5. ===============================================================
  6. ]]
  7.  
  8. --Check if Script is Local
  9. if script.ClassName ~= "LocalScript" then
  10. error("Script must be Local in order to work!")
  11. script.Parent = nil
  12. script.Disabled = true
  13. script:remove()
  14. script:Destroy()
  15. end
  16.  
  17. --------------------------------------
  18. -------------|Variables|--------------
  19. --------------------------------------
  20. local Player = game.Players.LocalPlayer
  21. local Version = "doge"
  22. local Box_Data = {
  23. ["Material"] = "Neon";
  24. ["BrickColor"] = BrickColor.new("Cyan");
  25. ["Transparency"] = 0.7;
  26. ["Reflectance"] = 0;
  27. ["Height"] = 10;
  28. }
  29.  
  30. --------------------------------------
  31. ----------|Creating a box|------------
  32. --------------------------------------
  33. local BoxModel = Instance.new("Model")
  34. BoxModel.Name = [[A box v]]..Version..[[ by Mokiros]]
  35.  
  36. local CreatePart = function (Name,Size,CFramePosition)
  37. local Part = Instance.new("Part",BoxModel)
  38. Part.Anchored = true
  39. Part.Locked = true
  40. Part.FormFactor = "Custom"
  41. Part.Material = Box_Data["Material"]
  42. Part.BrickColor = Box_Data["BrickColor"]
  43. Part.Transparency = Box_Data["Transparency"]
  44. Part.Reflectance = Box_Data["Reflectance"]
  45. Part.Name = Name
  46. Part.Size = Size
  47. Part.CFrame = CFramePosition
  48. return(Part)
  49. end
  50.  
  51.  
  52. local OxChat = function (msg1,msg2,plr)
  53. local SV = Instance.new('StringValue')
  54. SV.Parent = plr
  55. SV.Name = 'SB_Chat'
  56. SV.Value = ""..tostring(msg1):gsub('','\5').."/"..tostring(msg2):gsub('','\5')..""
  57. game.Debris:AddItem(SV, .1)
  58. end
  59.  
  60.  
  61.  
  62. --Creating parts
  63. local Base = CreatePart("Bottom",Vector3.new(10,1,10),CFrame.new(0,0,0))
  64. local Front = CreatePart("Front",Vector3.new(1,10,10),(Base.CFrame * CFrame.new(4.5,5,0)))
  65. local Back = CreatePart("Back",Vector3.new(1,10,10),(Base.CFrame * CFrame.new(-4.5,5,0)))
  66. local Left = CreatePart("Left",Vector3.new(10,10,1),(Base.CFrame * CFrame.new(0,5,-4.5)))
  67. local Right = CreatePart("Right",Vector3.new(10,10,1),(Base.CFrame * CFrame.new(0,5,4.5)))
  68. local Top = CreatePart("Top",Vector3.new(10,1,10),(Base.CFrame * CFrame.new(0,9.5,0)))
  69. BoxModel.PrimaryPart = Base
  70.  
  71.  
  72. --Creating BodyHolding stuff which makes The Box special
  73. local BP = Instance.new("BodyPosition",Base)
  74. BP.MaxForce = Vector3.new(0,math.huge,0)
  75. BP.Position = Vector3.new(0,Box_Data["Height"],0)
  76. local BG = Instance.new("BodyGyro",Base)
  77. BG.MaxTorque = Vector3.new(math.huge,0,math.huge)
  78. BG.CFrame = Base.CFrame
  79.  
  80.  
  81. --Welding everything together
  82. --local Welds_Folder = Instance.new("Folder",BoxModel)
  83. --Welds_Folder.Name = "Welds"
  84. for i,c in pairs(BoxModel:GetChildren()) do
  85. local Weld = Instance.new("Weld",Base)
  86. Weld.Part0 = Base
  87. Weld.Part1 = c
  88. Weld.C0 = Base.CFrame:inverse()
  89. Weld.C1 = c.CFrame:inverse()
  90. end
  91.  
  92.  
  93. for i,c in pairs(BoxModel:GetChildren()) do
  94. if c["Anchored"] then
  95. c.Anchored = false
  96. end
  97. end
  98.  
  99.  
  100. local Backup = BoxModel:Clone()
  101.  
  102. BoxModel.Parent = workspace
  103. script.Parent = Player.PlayerScripts
  104.  
  105. print("The Box v"..Version.." by Mokiros has been loaded!")
  106.  
  107. Player.Character:SetPrimaryPartCFrame(Player.Character.PrimaryPart.CFrame * CFrame.new(0,5,0))
  108. BoxModel:SetPrimaryPartCFrame(Player.Character.PrimaryPart.CFrame * CFrame.new(0,-5,0))
  109.  
  110. --Chat commands
  111. Player.Chatted:connect(function(msg)
  112. if msg:lower() == "restorebox" then
  113. if BoxModel ~= nil then
  114. BoxModel:Destroy()
  115. end
  116. BoxModel = Backup:Clone()
  117. for i,c in pairs(BoxModel:GetChildren()) do
  118. for i,v in pairs(Box_Data) do
  119. if i ~= "Height" and c[i] then
  120. c[i] = v
  121. end
  122. end
  123. end
  124. BoxModel:FindFirstChild("Bottom"):FindFirstChild("BodyPosition").Position
  125. = Vector3.new(0,Box_Data["Height"],0)
  126. BoxModel.Parent = workspace
  127. Player.Character:SetPrimaryPartCFrame(Player.Character.PrimaryPart.CFrame * CFrame.new(0,5,0))
  128. BoxModel:SetPrimaryPartCFrame(Player.Character.PrimaryPart.CFrame * CFrame.new(0,-5,0))
  129. elseif msg:sub(1,7) == "change/" then
  130. local SlashNum = 0
  131. for i = 8,#msg do
  132. if msg:sub(i,i) == "/" then
  133. SlashNum = i
  134. break
  135. end
  136. end
  137. if SlashNum ~= 0 then
  138. if msg:sub(8,SlashNum-1) == "Height" then
  139. BoxModel:FindFirstChild("Bottom"):FindFirstChild("BodyPosition").Position
  140. = Vector3.new(0,tonumber(msg:sub(SlashNum+1)),0)
  141. else
  142. for i,c in pairs(BoxModel:GetChildren()) do
  143. if c[msg:sub(8,SlashNum-1)] then
  144. if msg:sub(8,SlashNum-1) == "BrickColor" then
  145. c[msg:sub(8,SlashNum-1)] = BrickColor.new(msg:sub(SlashNum+1))
  146. else
  147. c[msg:sub(8,SlashNum-1)] = msg:sub(SlashNum+1)
  148. end
  149. end
  150. end
  151. end
  152. if msg:sub(8,SlashNum-1) == "BrickColor" then
  153. Box_Data[msg:sub(8,SlashNum-1)] = BrickColor.new(msg:sub(SlashNum+1))
  154. else
  155. Box_Data[msg:sub(8,SlashNum-1)] = msg:sub(SlashNum+1)
  156. end
  157. end
  158. elseif msg:lower() == "checkbox" then
  159. print("Box model:",tostring(BoxModel))
  160. print("Script:",tostring(script))
  161. print("Owner:",tostring(Player))
  162. end
  163. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement