Advertisement
Oscar55555

Untitled

Feb 21st, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.46 KB | None | 0 0
  1.  
  2. --https://github.com/Mokiros/roblox-FE-compatibility
  3. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  4. local Player,game,owner = owner,game
  5. local RealPlayer = Player
  6. do
  7. print("FE Compatibility code V2 by Mokiros")
  8. local RealPlayer = RealPlayer
  9. script.Parent = RealPlayer.Character
  10.  
  11. --Fake event to make stuff like Mouse.KeyDown work
  12. local Disconnect_Function = function(this)
  13. this[1].Functions[this[2]] = nil
  14. end
  15. local Disconnect_Metatable = {__index={disconnect=Disconnect_Function,Disconnect=Disconnect_Function}}
  16. local FakeEvent_Metatable = {__index={
  17. Connect = function(this,f)
  18. local i = tostring(math.random(0,10000))
  19. while this.Functions[i] do
  20. i = tostring(math.random(0,10000))
  21. end
  22. this.Functions[i] = f
  23. return setmetatable({this,i},Disconnect_Metatable)
  24. end
  25. }}
  26. FakeEvent_Metatable.__index.connect = FakeEvent_Metatable.__index.Connect
  27. local function fakeEvent()
  28. return setmetatable({Functions={}},FakeEvent_Metatable)
  29. end
  30.  
  31. --Creating fake input objects with fake variables
  32. local FakeMouse = {Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent(),Button2Up=fakeEvent(),Button2Down=fakeEvent()}
  33. FakeMouse.keyUp = FakeMouse.KeyUp
  34. FakeMouse.keyDown = FakeMouse.KeyDown
  35. local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  36. local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  37. CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  38. end}
  39. --Merged 2 functions into one by checking amount of arguments
  40. CAS.UnbindAction = CAS.BindAction
  41.  
  42. --This function will trigger the events that have been :Connect()'ed
  43. local function TriggerEvent(self,ev,...)
  44. for _,f in pairs(self[ev].Functions) do
  45. f(...)
  46. end
  47. end
  48. FakeMouse.TriggerEvent = TriggerEvent
  49. UIS.TriggerEvent = TriggerEvent
  50.  
  51. --Client communication
  52. local Event = Instance.new("RemoteEvent")
  53. Event.Name = "UserInput_Event"
  54. Event.OnServerEvent:Connect(function(plr,io)
  55. if plr~=RealPlayer then return end
  56. FakeMouse.Target = io.Target
  57. FakeMouse.Hit = io.Hit
  58. if not io.isMouse then
  59. local b = io.UserInputState == Enum.UserInputState.Begin
  60. if io.UserInputType == Enum.UserInputType.MouseButton1 then
  61. return FakeMouse:TriggerEvent(b and "Button1Down" or "Button1Up")
  62. end
  63. if io.UserInputType == Enum.UserInputType.MouseButton2 then
  64. return FakeMouse:TriggerEvent(b and "Button2Down" or "Button2Up")
  65. end
  66. for _,t in pairs(CAS.Actions) do
  67. for _,k in pairs(t.Keys) do
  68. if k==io.KeyCode then
  69. t.Function(t.Name,io.UserInputState,io)
  70. end
  71. end
  72. end
  73. FakeMouse:TriggerEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  74. UIS:TriggerEvent(b and "InputBegan" or "InputEnded",io,false)
  75. end
  76. end)
  77. Event.Parent = NLS([==[local Event = script:WaitForChild("UserInput_Event")
  78. local Mouse = owner:GetMouse()
  79. local UIS = game:GetService("UserInputService")
  80. local input = function(io,RobloxHandled)
  81. if RobloxHandled then return end
  82. --Since InputObject is a client-side instance, we create and pass table instead
  83. Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState,Hit=Mouse.Hit,Target=Mouse.Target})
  84. end
  85. UIS.InputBegan:Connect(input)
  86. UIS.InputEnded:Connect(input)
  87.  
  88. local h,t
  89. --Give the server mouse data every second frame, but only if the values changed
  90. --If player is not moving their mouse, client won't fire events
  91. local HB = game:GetService("RunService").Heartbeat
  92. while true do
  93. if h~=Mouse.Hit or t~=Mouse.Target then
  94. h,t=Mouse.Hit,Mouse.Target
  95. Event:FireServer({isMouse=true,Target=t,Hit=h})
  96. end
  97. --Wait 2 frames
  98. for i=1,2 do
  99. HB:Wait()
  100. end
  101. end]==],script)
  102.  
  103. ----Sandboxed game object that allows the usage of client-side methods and services
  104. --Real game object
  105. local RealGame = game
  106.  
  107. --Metatable for fake service
  108. local FakeService_Metatable = {
  109. __index = function(self,k)
  110. local s = rawget(self,"_RealService")
  111. if s then
  112. return typeof(s[k])=="function"
  113. and function(_,...)return s[k](s,...)end or s[k]
  114. end
  115. end,
  116. __newindex = function(self,k,v)
  117. local s = rawget(self,"_RealService")
  118. if s then s[k]=v end
  119. end
  120. }
  121. local function FakeService(t,RealService)
  122. t._RealService = typeof(RealService)=="string" and RealGame:GetService(RealService) or RealService
  123. return setmetatable(t,FakeService_Metatable)
  124. end
  125.  
  126. --Fake game object
  127. local FakeGame = {
  128. GetService = function(self,s)
  129. return rawget(self,s) or RealGame:GetService(s)
  130. end,
  131. Players = FakeService({
  132. LocalPlayer = FakeService({GetMouse=function(self)return FakeMouse end},Player)
  133. },"Players"),
  134. UserInputService = FakeService(UIS,"UserInputService"),
  135. ContextActionService = FakeService(CAS,"ContextActionService"),
  136. RunService = FakeService({
  137. _btrs = {},
  138. RenderStepped = RealGame:GetService("RunService").Heartbeat,
  139. BindToRenderStep = function(self,name,_,fun)
  140. self._btrs[name] = self.Heartbeat:Connect(fun)
  141. end,
  142. UnbindFromRenderStep = function(self,name)
  143. self._btrs[name]:Disconnect()
  144. end,
  145. },"RunService")
  146. }
  147. rawset(FakeGame.Players,"localPlayer",FakeGame.Players.LocalPlayer)
  148. FakeGame.service = FakeGame.GetService
  149. FakeService(FakeGame,game)
  150. --Changing owner to fake player object to support owner:GetMouse()
  151. game,owner = FakeGame,FakeGame.Players.LocalPlayer
  152. end
  153. me = game.Players.BlindParsley157 --add your name here CLICK "Q" to see the settings
  154.  
  155. if script.Parent.className ~= "HopperBin" then
  156. h = Instance.new("HopperBin")
  157. h.Parent = me.Backpack
  158. h.Name = "Build IT"
  159. script.Parent = h
  160. end
  161.  
  162. bin = script.Parent
  163. hold = false
  164. sel = false
  165.  
  166. color = "Black"
  167. material = "Plastic"
  168. x = 1
  169. y = 1
  170. tran = 0
  171. ref = 0
  172.  
  173. colours = {}
  174. materials = {"Plastic", "Wood", "Slate", "CorrodedMetal", "Concrete", "Ice", "Foil", "Grass", "DiamondPlate"}
  175. floor = {}
  176.  
  177. for i=1,1032 do
  178. if BrickColor.new(i) ~= BrickColor.new("Medium stone grey") then
  179. table.insert(colours, tostring(BrickColor.new(i)))
  180. end
  181. end
  182.  
  183. brick = Instance.new("Part")
  184. brick.Parent = bin
  185. brick.formFactor = 0
  186. brick.Size = Vector3.new(1,1,1)
  187. brick.Anchored = true
  188. brick.BrickColor = BrickColor.new(color)
  189. brick.TopSurface = 0
  190. brick.BottomSurface = 0
  191. brick.Material = material
  192. brick.CanCollide = false
  193. brick.Transparency = tran
  194. brick.Reflectance = ref
  195. brick.Size = Vector3.new(x,y,1)
  196. sph = Instance.new("SpecialMesh",brick)
  197. sph.MeshType = "Brick"
  198. sph.Scale = Vector3.new(x,y,1)
  199.  
  200. mode = "Build"
  201. gui = false
  202.  
  203. function lollero(vector)
  204. return Vector3.new(math.ceil(vector.x - 0.5), math.ceil(vector.y - 0.5), math.ceil(vector.z - 0.5))
  205. end
  206.  
  207. function makegui()
  208. if gui == true then return end
  209. screen = Instance.new("ScreenGui")
  210. screen.Parent = me.PlayerGui
  211. screen.Name = "Build GUI"
  212. frame = Instance.new("Frame")
  213. frame.Parent = screen
  214. frame.Size = UDim2.new(1,0,0.078,0)
  215. frame.Position = UDim2.new(0,0,0,-1)
  216. frame.BackgroundColor3 = Color3.new(0.05,0.05,0.05)
  217. frame.BorderColor3 = Color3.new(0.17,0.17,0.17)
  218. local xx = 0.045
  219. local yy = 0.1
  220. for i=1, #colours do
  221. local button = Instance.new("TextButton",frame)
  222. button.Size = UDim2.new(0.014,0,0.26,0)
  223. button.Position = UDim2.new(xx,0,yy,0)
  224. button.BackgroundColor = BrickColor.new(colours[i])
  225. button.BorderSizePixel = 0
  226. button.Text = ""
  227. button.MouseButton1Click:connect(function()
  228. color = colours[i]
  229. end)
  230. xx = xx + 0.016
  231. if xx > 0.8 then
  232. xx = 0.045
  233. yy = yy + 0.3
  234. end
  235. end
  236. frame2 = Instance.new("Frame")
  237. frame2.Parent = screen
  238. frame2.Size = UDim2.new(0.1,0,1,0)
  239. frame2.Position = UDim2.new(0.9,0,0,-1)
  240. frame2.BackgroundColor3 = Color3.new(0.05,0.05,0.05)
  241. frame2.BorderColor3 = Color3.new(0.17,0.17,0.17)
  242. local yyy = 0.14
  243. for i=1, #materials do
  244. local butta = Instance.new("TextButton",frame2)
  245. butta.Size = UDim2.new(0.8,0,0.06,0)
  246. butta.Position = UDim2.new(0.1,0,yyy,0)
  247. butta.BackgroundColor3 = Color3.new(0.1,0.1,0.1)
  248. butta.Text = materials[i]
  249. butta.BorderColor3 = Color3.new(0.2,0.2,0.2)
  250. butta.TextColor3 = Color3.new(1,1,1)
  251. butta.MouseButton1Click:connect(function()
  252. material = materials[i]
  253. end)
  254. yyy = yyy + 0.067
  255. end
  256. floorbutton = Instance.new("TextButton",frame2)
  257. floorbutton.Size = UDim2.new(0.9,0,0.07,0)
  258. floorbutton.Position = UDim2.new(0.05,0,0.8,0)
  259. floorbutton.BackgroundColor3 = Color3.new(0.1,0.1,0.1)
  260. floorbutton.Text = "Done"
  261. floorbutton.BorderColor3 = Color3.new(0.2,0.2,0.2)
  262. floorbutton.TextColor3 = Color3.new(1,1,1)
  263. floorbutton.FontSize = "Size14"
  264. floorbutton.MouseButton1Click:connect(function()
  265. for i=1, #floor do
  266. floor[i].Parent = workspace
  267. end
  268. for i=1, #floor do
  269. table.remove(floor,1)
  270. end
  271. end)
  272. instructions = Instance.new("Frame",screen)
  273. instructions.Size = UDim2.new(1,0,0.08,0)
  274. instructions.Position = UDim2.new(0,0,0.92,0)
  275. instructions.BackgroundColor3 = Color3.new(0.1,0.1,0.1)
  276. text1 = Instance.new("TextLabel",instructions)
  277. text1.Size = UDim2.new(1,0,0.4,0)
  278. text1.Position = UDim2.new(0,0,0,0)
  279. text1.BackgroundTransparency = 1
  280. text1.FontSize = "Size18"
  281. text1.TextColor3 = Color3.new(1,1,1)
  282. text1.Text = "R, T, Z, X to resize, Y and U for transparency, E to remove gui."
  283. text2 = Instance.new("TextLabel",instructions)
  284. text2.Size = UDim2.new(1,0,0.4,0)
  285. text2.Position = UDim2.new(0,0,0.5,0)
  286. text2.BackgroundTransparency = 1
  287. text2.FontSize = "Size18"
  288. text2.TextColor3 = Color3.new(1,1,1)
  289. text2.Text = "B for build mode, F for deleting mode, M for edit mode."
  290. gui = true
  291. end
  292.  
  293. bin.Selected:connect(function(mouse)
  294. sel = true
  295. brick.Parent = me.Character
  296. brick.CFrame = CFrame.new(mouse.Hit.p)
  297. coroutine.resume(coroutine.create(function()
  298. while sel do
  299. wait()
  300. brick.CFrame = CFrame.new(lollero(mouse.Hit.p)) * CFrame.new(0,y/2,0)
  301. brick.BrickColor = BrickColor.new(color)
  302. brick.Material = material
  303. brick.Transparency = tran
  304. brick.Reflectance = ref
  305. sph.Scale = Vector3.new(x,y,1)
  306. end
  307. end))
  308. mouse.KeyDown:connect(function(key)
  309. key = key:lower()
  310. if key == "q" then
  311. makegui()
  312. elseif key == "e" then
  313. local a = me.PlayerGui:GetChildren()
  314. for _,v in pairs(a) do
  315. if v.Name == "Build GUI" then
  316. v:remove()
  317. gui = false
  318. end
  319. end
  320. elseif key == "z" then
  321. if x > 1 then
  322. x = x - 1
  323. end
  324. elseif key == "x" then
  325. x = x + 1
  326. elseif key == "r" then
  327. if y > 1 then
  328. y = y - 1
  329. end
  330. elseif key == "t" then
  331. y = y + 1
  332. elseif key == "f" then
  333. mode = "Delete"
  334. elseif key == "b" then
  335. mode = "Build"
  336. elseif key == "m" then
  337. mode = "Edit"
  338. elseif key == "y" then
  339. tran = tran - 0.1
  340. if tran < 0 then
  341. tran = 0
  342. end
  343. elseif key == "u" then
  344. tran = tran + 0.1
  345. if tran > 1 then
  346. tran = 1
  347. end
  348. end
  349. end)
  350. mouse.Button1Down:connect(function()
  351. if mode == "Build" then
  352. if mouse.Target == nil then return end
  353. hold = true
  354. holdem = lollero(mouse.Hit.p)
  355. holdposition = holdem + Vector3.new(0,y/2,0)
  356. possa = holdposition
  357. local buildbrick = Instance.new("Part",me.Character)
  358. buildbrick.Name = "BuildBrick"
  359. buildbrick.formFactor = "Custom"
  360. buildbrick.Size = Vector3.new(x,y,1)
  361. buildbrick.TopSurface = 0
  362. buildbrick.BottomSurface = 0
  363. buildbrick.Anchored = true
  364. buildbrick.BrickColor = BrickColor.new(color)
  365. buildbrick.Transparency = tran
  366. buildbrick.Reflectance = ref
  367. buildbrick.Material = material
  368. buildbrick.CFrame = CFrame.new(holdposition)
  369. table.insert(floor,buildbrick)
  370. while hold do
  371. holdposition = holdem + Vector3.new(0,y/2,0)
  372. local poo = lollero(mouse.Hit.p)
  373. possa = poo + Vector3.new(0,y/2,0)
  374. local distance = (holdposition - possa).magnitude
  375. if distance > 600 then
  376. distance = 600
  377. end
  378. buildbrick.Size = Vector3.new(x,y,distance)
  379. buildbrick.CFrame = CFrame.new((possa + holdposition)/2, holdposition)
  380. wait()
  381. end
  382. elseif mode == "Delete" then
  383. if mouse.Target then
  384. local targ = mouse.Target
  385. if targ.Name == "BuildBrick" then
  386. targ:remove()
  387. end
  388. end
  389. elseif mode == "Edit" then
  390. if mouse.Target then
  391. local targ = mouse.Target
  392. if targ.Name == "BuildBrick" then
  393. targ.BrickColor = BrickColor.new(color)
  394. targ.Material = material
  395. targ.Transparency = tran
  396. targ.Reflectance = ref
  397. end
  398. end
  399. end
  400. end)
  401. mouse.Button1Up:connect(function()
  402. hold = false
  403. end)
  404. end)
  405.  
  406. bin.Deselected:connect(function()
  407. hold = false
  408. sel = false
  409. brick.Parent = bin
  410. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement