Advertisement
HenloMyDude

TERRAIN MAKER GUI

Nov 24th, 2019
460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.68 KB | None | 0 0
  1.  
  2. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  3. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  4. local RealPlayer = Player
  5. do print("FE Compatibility code by Mokiros")local a=RealPlayer;script.Parent=a.Character;local b=Instance.new("RemoteEvent")b.Name="UserInput_Event"local function c()local d={_fakeEvent=true,Functions={},Connect=function(self,e)table.insert(self.Functions,e)end}d.connect=d.Connect;return d end;local f={Target=nil,Hit=CFrame.new(),KeyUp=c(),KeyDown=c(),Button1Up=c(),Button1Down=c(),Button2Up=c(),Button2Down=c()}local g={InputBegan=c(),InputEnded=c()}local CAS={Actions={},BindAction=function(self,h,i,j,...)CAS.Actions[h]=i and{Name=h,Function=i,Keys={...}}or nil end}CAS.UnbindAction=CAS.BindAction;local function k(self,l,...)local d=f[l]if d and d._fakeEvent then for m,e in pairs(d.Functions)do e(...)end end end;f.TrigEvent=k;g.TrigEvent=k;b.OnServerEvent:Connect(function(n,o)if n~=a then return end;f.Target=o.Target;f.Hit=o.Hit;if not o.isMouse then local p=o.UserInputState==Enum.UserInputState.Begin;if o.UserInputType==Enum.UserInputType.MouseButton1 then return f:TrigEvent(p and"Button1Down"or"Button1Up")end;if o.UserInputType==Enum.UserInputType.MouseButton2 then return f:TrigEvent(p and"Button2Down"or"Button2Up")end;for m,d in pairs(CAS.Actions)do for m,q in pairs(d.Keys)do if q==o.KeyCode then d.Function(d.Name,o.UserInputState,o)end end end;f:TrigEvent(p and"KeyDown"or"KeyUp",o.KeyCode.Name:lower())g:TrigEvent(p and"InputBegan"or"InputEnded",o,false)end end)b.Parent=NLS([==[local a=game:GetService("Players").LocalPlayer;local b=script:WaitForChild("UserInput_Event")local c=a:GetMouse()local d=game:GetService("UserInputService")local e=function(f,g)if g then return end;b:FireServer({KeyCode=f.KeyCode,UserInputType=f.UserInputType,UserInputState=f.UserInputState,Hit=c.Hit,Target=c.Target})end;d.InputBegan:Connect(e)d.InputEnded:Connect(e)local h,i;while wait(1/30)do if h~=c.Hit or i~=c.Target then h,i=c.Hit,c.Target;b:FireServer({isMouse=true,Target=i,Hit=h})end end]==],Player.Character)local r=game;local s={__index=function(self,q)local t=rawget(self,"_RealService")if t then return typeof(t[q])=="function"and function(m,...)return t[q](t,...)end or t[q]end end,__newindex=function(self,q,u)local t=rawget(self,"_RealService")if t then t[q]=u end end}local function v(d,w)d._RealService=typeof(w)=="string"and r:GetService(w)or w;return setmetatable(d,s)end;local x={GetService=function(self,t)return rawget(self,t)or r:GetService(t)end,Players=v({LocalPlayer=v({GetMouse=function(self)return f end},Player)},"Players"),UserInputService=v(g,"UserInputService"),ContextActionService=v(CAS,"ContextActionService"),RunService=v({_btrs={},RenderStepped=r:GetService("RunService").Heartbeat,BindToRenderStep=function(self,h,m,i)self._btrs[h]=self.Heartbeat:Connect(i)end,UnbindFromRenderStep=function(self,h)self._btrs[h]:Disconnect()end},"RunService")}rawset(x.Players,"localPlayer",x.Players.LocalPlayer)x.service=x.GetService;v(x,game)game,owner=x,x.Players.LocalPlayer end
  6.  
  7. plr = owner
  8. mouse = plr:GetMouse()
  9. plrgui = plr.PlayerGui
  10. hasbrush = false
  11.  
  12. local gui = Instance.new("ScreenGui",plrgui)
  13. gui.Name = "TerrainMakerGui"
  14. gui.Enabled = true
  15.  
  16. local scroll = Instance.new("ScrollingFrame",gui)
  17. scroll.Size = UDim2.new(0, 440, 0, 500)
  18. scroll.Name = "Scroll"
  19. scroll.Active = true
  20. scroll.Draggable = true
  21.  
  22. local remote1 = Instance.new("RemoteEvent",scroll)
  23. remote1.Name = "SeaRemote"
  24. local remote2 = Instance.new("RemoteEvent",scroll)
  25. remote2.Name = "MaterialRemote"
  26. local remote3 = Instance.new("RemoteEvent",scroll)
  27. remote3.Name = "SizeRemote"
  28.  
  29. function createtext(text, position, name)
  30. local thing = Instance.new("TextLabel",scroll)
  31. thing.Text = text
  32. thing.Name = name
  33. thing.TextScaled = true
  34. thing.Position = position
  35. thing.BackgroundTransparency = 0
  36. thing.BorderSizePixel = 1
  37. thing.BorderMode = "Outline"
  38. thing.Size = UDim2.new(0, 200, 0, 50)
  39. return thing
  40. end
  41.  
  42. function createbutton(text, position, name)
  43. local thing = Instance.new("TextButton",scroll)
  44. thing.Text = text
  45. thing.Name = name
  46. thing.TextScaled = true
  47. thing.Position = position
  48. thing.BackgroundTransparency = 0
  49. thing.BorderSizePixel = 1
  50. thing.BorderMode = "Outline"
  51. thing.Size = UDim2.new(0, 200, 0, 50)
  52. return thing
  53. end
  54.  
  55. function createbox(text, position, name)
  56. local thing = Instance.new("TextBox",scroll)
  57. thing.Text = text
  58. thing.Name = name
  59. thing.TextScaled = true
  60. thing.Position = position
  61. thing.BackgroundTransparency = 0
  62. thing.BorderSizePixel = 1
  63. thing.BorderMode = "Outline"
  64. thing.Size = UDim2.new(0, 200, 0, 50)
  65. return thing
  66. end
  67.  
  68. last = "a"
  69.  
  70. function addground()
  71. local poot = Instance.new("Part",workspace)
  72. poot.Transparency = 1
  73. poot.Position = Vector3.new(0, 2, 0)
  74. poot.Size = Vector3.new(700.091187, 0, 700.175964)
  75. poot.CanCollide = false
  76. poot.Anchored = true
  77. workspace.Terrain:FillBlock(poot.CFrame, poot.Size, material)
  78. wait()
  79. poot:remove()
  80. end
  81.  
  82. local seal = createbox("Sea Level", UDim2.new(0, 0, 0, 0), "SeaLevel")
  83. seal.Text = "Sea Level"
  84. last = seal
  85. local applyl = createbutton("Apply Sea Level", last.Position + UDim2.new(0.45, 0, 0, 0), "ApplySeaLevel")
  86. last = applyl
  87. local clear = createbutton("Clear All Terrain", seal.Position + UDim2.new(0, 0, 0.025, 0), "ClearTerrain")
  88. clear.MouseButton1Click:connect(function()
  89. local poot = Instance.new("Part",workspace)
  90. poot.Transparency = 1
  91. poot.Position = Vector3.new(0, 0, 0)
  92. poot.Size = Vector3.new(900, 900, 900)
  93. poot.CanCollide = false
  94. poot.Anchored = true
  95. workspace.Terrain:FillBlock(poot.CFrame, poot.Size, Enum.Material.Air)
  96. wait()
  97. poot:remove()
  98. end)
  99. last = clear
  100. local mat = createbox("Change Material", clear.Position + UDim2.new(0, 0, 0.05, 0), "ChangeMaterial")
  101. mat.Text = "Change Material"
  102. last = mat
  103. local toggleb = createbutton("Toggle Brush", last.Position + UDim2.new(0, 0, 0.025, 0), "ToggleBrush")
  104. toggleb.MouseButton1Click:connect(function()
  105. if hasbrush then
  106. hasbrush = false
  107. else
  108. hasbrush = true
  109. end
  110. end)
  111. last = toggleb
  112. local textmats = createtext("Brush Stuff", clear.Position + UDim2.new(0, 0, 0.025, 0), "BrushStuff")
  113. textmats.Size = UDim2.new(0, 450, 0, 50)
  114. local applym = createbutton("Apply Material", mat.Position + UDim2.new(0.45, 0, 0, 0), "ApplyMaterial")
  115. last = applym
  116. local generateg = createbutton("Generate Random Grass", toggleb.Position + UDim2.new(0.45, 0, 0, 0), "GenerateGrass")
  117. generateg.MouseButton1Click:connect(function()
  118. generaterandomgrass()
  119. end)
  120. local ssize = createbox("Set Size", toggleb.Position + UDim2.new(0, 0, 0.025, 0), "SetSize")
  121. last = ssize
  122. local applys = createbutton("Apply Size", last.Position + UDim2.new(0.45, 0, 0, 0), "ApplySize")
  123. last = applys
  124. local makef = createbutton("Generate Floor", ssize.Position + UDim2.new(0, 0, 0.025, 0), "GenerateFloor")
  125. makef.MouseButton1Click:connect(function()
  126. addground()
  127. end)
  128. last = makef
  129.  
  130. NLS([[
  131.  
  132. plr = owner
  133. plrgui = plr.PlayerGui
  134. gui = plrgui.TerrainMakerGui
  135. scroll = gui.Scroll
  136. seal = scroll.SeaLevel
  137. applyl = scroll.ApplySeaLevel
  138. mat = scroll.ChangeMaterial
  139. applym = scroll.ApplyMaterial
  140. ssize = scroll.SetSize
  141. applys = scroll.ApplySize
  142. remote1 = scroll.SeaRemote
  143. remote2 = scroll.MaterialRemote
  144. remote3 = scroll.SizeRemote
  145.  
  146. applyl.MouseButton1Click:connect(function()
  147. remote1:FireServer(seal.Text)
  148. end)
  149.  
  150. applym.MouseButton1Click:connect(function()
  151. remote2:FireServer(mat.Text)
  152. end)
  153.  
  154. applys.MouseButton1Click:connect(function()
  155. remote3:FireServer(ssize.Text)
  156. end)
  157.  
  158. ]],plr.Character)
  159.  
  160. material = "Grass"
  161. hold = false
  162.  
  163. function generaterandomgrass()
  164. print("taken from my random terrain generator script")
  165. ------------------------------------------------------------------------------------
  166. max_x = 800
  167. min_x = 50
  168. max_y = 50
  169. min_y = -1
  170. max_z = 800
  171. min_z = 50
  172. posmax = 200
  173. sposmax = 500
  174. posmin = -200
  175. sposmin = -500
  176. maxgrass = 5000
  177. maxsand = 5000
  178. maxsx = 1000
  179. minsx = -1000
  180. maxsy = -0
  181. minsy = -0.5
  182. maxsz = 400
  183. minsz = -400
  184. ------------------------------------------------------------------------------------
  185.  
  186. coroutine.resume(coroutine.create(function()
  187. --Grass
  188. for i = 1,maxgrass do
  189. local x = math.random(min_x, max_x)
  190. local y = math.random(min_y, max_y)
  191. local z = math.random(min_z,max_z)
  192. local x2 = math.random(posmin, posmax)
  193. game.Workspace.Terrain:FillBlock(CFrame.new(x2, y, x2), Vector3.new(x, y, z), Enum.Material.Grass)
  194. end
  195. wait()
  196. for i = 1,maxgrass do
  197. local x = math.random(min_x, max_x)
  198. local y = math.random(min_y, max_y)
  199. local z = math.random(min_z,max_z)
  200. local x2 = math.random(posmin, posmax)
  201. game.Workspace.Terrain:FillBlock(CFrame.new(x2, y, x2), Vector3.new(x, y, z), Enum.Material.Grass)
  202. end
  203. wait()
  204. for i = 1,maxgrass do
  205. local x = math.random(min_x, max_x)
  206. local y = math.random(min_y, max_y)
  207. local z = math.random(min_z,max_z)
  208. local x2 = math.random(posmin, posmax)
  209. game.Workspace.Terrain:FillBlock(CFrame.new(x2, y, x2), Vector3.new(x, y, z), Enum.Material.Grass)
  210. end
  211. end))
  212. wait(1)
  213. posmax = 200
  214. sposmax = 500
  215. posmin = -200
  216. sposmin = -500
  217. maxgrass = 5000
  218. maxsand = 5000
  219. maxsx = 1000
  220. minsx = -1000
  221. maxsy = -0
  222. minsy = -0.5
  223. maxsz = 400
  224. minsz = -400
  225. coroutine.resume(coroutine.create(function()
  226. --Sand
  227. for i = 1,maxsand do
  228. local x = math.random(minsx, maxsx)
  229. local y = math.random(minsy, maxsy)
  230. local z = math.random(minsz,maxsz)
  231. local x2 = math.random(sposmin, sposmax)
  232. game.Workspace.Terrain:FillBlock(CFrame.new(0, y, 0), Vector3.new(1200, y, 1200), Enum.Material.Sand)
  233. end
  234. end))
  235. end
  236.  
  237. size = 2
  238.  
  239. function sealocal(player, texto)
  240. local y = string.match(texto, "%d+")
  241. print(y)
  242. local poot = Instance.new("Part",workspace)
  243. poot.Transparency = 1
  244. poot.Position = Vector3.new(0, y / 2, 0)
  245. poot.Size = Vector3.new(700.091187, y, 700.175964)
  246. poot.CanCollide = false
  247. poot.Anchored = true
  248. workspace.Terrain:FillBlock(poot.CFrame, poot.Size, Enum.Material.Water)
  249. wait()
  250. poot:remove()
  251. end
  252.  
  253. function changesize(player, texto)
  254. size = texto
  255. end
  256.  
  257. function changemat(player, texto)
  258. material = texto
  259. end
  260.  
  261. mouse.Button1Down:connect(function()
  262. if hasbrush then
  263. hold = true
  264. repeat
  265. wait()
  266. local poot = Instance.new("Part",workspace)
  267. poot.Transparency = 1
  268. poot.Position = mouse.Hit.p
  269. poot.Size = Vector3.new(size, size, size)
  270. poot.CanCollide = false
  271. poot.Anchored = true
  272. workspace.Terrain:FillBlock(poot.CFrame, poot.Size, material)
  273. wait()
  274. poot:remove()
  275. until hold == false
  276. end
  277. end)
  278.  
  279. mouse.Button1Up:connect(function()
  280. hold = false
  281. end)
  282.  
  283. remote1.OnServerEvent:connect(sealocal)
  284. remote2.OnServerEvent:connect(changemat)
  285. remote3.OnServerEvent:connect(changesize)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement