Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local hasLoaded = plugin:GetSetting("pluginHasLoaded")
- if not hasLoaded then
- plugin:SetSetting("pluginHasLoaded", true)
- end
- local toolbar = plugin:CreateToolbar("Tree Brush")
- local button = toolbar:CreateButton(
- "Tree Brush",
- "",
- "http://www.roblox.com/asset/?id=216846095"
- )
- local ChangeHistoryService = game:GetService("ChangeHistoryService")
- function createGui()
- local ScreenGui = Instance.new("ScreenGui")
- ScreenGui.Parent = workspace
- local Frame1 = Instance.new("Frame")
- Frame1.Name = "Frame1"
- Frame1.Parent = ScreenGui
- Frame1.BackgroundTransparency = 0.5
- Frame1.BackgroundColor3 = Color3.new(1,1,1)
- Frame1.Position = UDim2.new(0,20,0,20)
- Frame1.Size = UDim2.new(0,150,0,250)
- local Frame = Instance.new("Frame")
- Frame.Name = "Frame"
- Frame.Parent = Frame1
- Frame.BackgroundTransparency = 1
- Frame.BackgroundColor3 = Color3.new(1,1,1)
- Frame.Position = UDim2.new(0,10,0,10)
- Frame.Size = UDim2.new(1,-20,1,-20)
- local Size = Instance.new("TextButton")
- Size.Name = "Size1"
- Size.Parent = Frame
- Size.BackgroundTransparency = 1
- Size.BackgroundColor3 = Color3.new(1,1,1)
- Size.Position = UDim2.new(0,0,0,0)
- Size.Size = UDim2.new(1,0,0,10)
- Size.Text = "Size"
- local Size_Slider = Instance.new("TextButton")
- Size_Slider.Name = "Size_Slider"
- Size_Slider.Parent = Frame
- Size_Slider.BackgroundTransparency = 0
- Size_Slider.BackgroundColor3 = Color3.new(0,0,0)
- Size_Slider.Position = UDim2.new(0,0,0,25)
- Size_Slider.Size = UDim2.new(1,0,0,2)
- Size_Slider.Text = ""
- local Button = Instance.new("TextButton")
- Button.Name = "Button"
- Button.Parent = Size_Slider
- Button.BackgroundTransparency = 0
- Button.BackgroundColor3 = Color3.new(1,1,1)
- Button.Position = UDim2.new(0,-8,0,-8)
- Button.Size = UDim2.new(0,16,0,16)
- Button.Text = ""
- local Density = Instance.new("TextButton")
- Density.Name = "Density"
- Density.Parent = Frame
- Density.BackgroundTransparency = 1
- Density.BackgroundColor3 = Color3.new(1,1,1)
- Density.Position = UDim2.new(0,0,0,50)
- Density.Size = UDim2.new(1,0,0,10)
- Density.Text = "Density"
- local Density_Slider = Instance.new("TextButton")
- Density_Slider.Name = "Density_Slider"
- Density_Slider.Parent = Frame
- Density_Slider.BackgroundTransparency = 0
- Density_Slider.BackgroundColor3 = Color3.new(0,0,0)
- Density_Slider.Position = UDim2.new(0,0,0,75)
- Density_Slider.Size = UDim2.new(1,0,0,2)
- Density_Slider.Text = ""
- local Button = Instance.new("TextButton")
- Button.Name = "Button"
- Button.Parent = Density_Slider
- Button.BackgroundTransparency = 0
- Button.BackgroundColor3 = Color3.new(1,1,1)
- Button.Position = UDim2.new(0,-8,0,-8)
- Button.Size = UDim2.new(0,16,0,16)
- Button.Text = ""
- return ScreenGui
- end
- Gui,Size,Density,SValue,DValue,Clicked = nil,nil,nil,nil,nil,false
- button.Click:connect(function()
- if plugin:IsActivated() then
- plugin:Deactivate()
- Gui:Destroy()
- Sphere.Parent = nil
- else
- plugin:Activate(true) -- Neccessary to listen to mouse input'
- Gui = createGui()
- Gui.Parent = game.CoreGui
- Size = Gui.Frame1.Frame.Size_Slider
- Density = Gui.Frame1.Frame.Density_Slider
- SValue = 50
- DValue = 1
- GuiPress()
- local Trees = workspace:FindFirstChild("Trees")
- if Trees == nil or not Trees:IsA("Folder") then
- local Trees = Instance.new("Folder")
- Trees.Parent = workspace
- Trees.Name = "Trees"
- end
- end
- end)
- -- function
- function createSphere(Size)
- local Ball = Instance.new("Part")
- Ball.Shape = Enum.PartType.Ball
- Ball.Size = Vector3.new(Size,Size,Size)
- Ball.Anchored = true
- Ball.Transparency = 0.75
- Ball.BrickColor = BrickColor.new("Bright red")
- Ball.TopSurface = Enum.SurfaceType.Smooth
- Ball.BottomSurface = Enum.SurfaceType.Smooth
- return Ball
- end
- -- Setup mouse
- local mouse = plugin:GetMouse()
- Pressed = false
- Sphere = createSphere(50)
- mouse.Button1Down:connect(function() -- Binds function to left click
- if game.ServerStorage:FindFirstChild("Trees") ~= nil then
- Pressed = true
- Sphere.Parent = workspace.Trees
- mouse.TargetFilter = workspace.Trees
- repeat
- local target = mouse.Target
- local hit = mouse.Hit
- local Touching = Sphere:GetTouchingParts()
- Sphere.CFrame = CFrame.new(mouse.Hit.p)
- NumberOfTrees = SValue * (DValue/100)--.5 Tree per stud max, .02 Trees per stud min
- for i = 1,NumberOfTrees do
- if #Touching < NumberOfTrees then
- PlaceTree(Sphere.Position)
- end
- end
- wait()
- until Pressed == false
- Sphere.Transparency = 0.95
- ChangeHistoryService:SetWaypoint("Drew Terrain")
- else
- print("Tree folder missing from game.ServerStorage")
- end
- end)
- mouse.Button1Up:connect(function()
- if Clicked then
- Clicked = false
- end
- Pressed = false
- repeat wait()
- Sphere.CFrame = mouse.Hit
- until Pressed or not plugin:IsActivated()
- end)
- function PlaceTree(Position)
- local CF = CFrame.new(Position) * CFrame.Angles(0,math.rad(math.random(0,360)),0)
- CF = CF * CFrame.new(math.random(0,Sphere.Size.z/2),0,0)
- Position = CF.p
- local Start = Vector3.new(Position.x,300,Position.z)
- local End = Vector3.new(Position.x,0,Position.z)
- local ray = Ray.new(Start, (End - Start).unit*750)
- local part,pos = workspace:FindPartOnRay(ray,workspace.Trees)
- if part ~= nil then
- local T = game.ServerStorage.Trees:GetChildren()
- local t = math.random(1,#T)
- local tree = T[t]:clone()
- local size = math.random(70,120)/100
- tree.Size = tree.Size*size
- tree.CFrame = CFrame.new(pos.x,pos.y,pos.z)*CFrame.Angles(0,math.rad(math.random(0,359)),0)*CFrame.new(0,tree.Size.Y/2-0.4,0)
- tree.Parent = workspace.Trees
- end
- end
- function GuiPress()
- Size.Button.MouseButton1Down:connect(function()
- Clicked = true
- repeat
- Size.Button.Position = UDim2.new(0,math.clamp(mouse.x - Size.AbsolutePosition.x - 8,-8,122),0,-8)
- -- -8, 122
- --SValue = math.clamp(math.floor((Size.Button.Position.X.Offset / 130) * 100)/100,.25,1)*200
- SValue = math.floor(math.clamp(((Size.Button.Position.X.Offset + 8)/130)+.05,.05,1) * 1000)
- Sphere.Size = Vector3.new(SValue,SValue,SValue)
- Gui.Frame1.Frame.Size1.Text = "Size: "..SValue
- wait()
- until Clicked == false
- end)
- Density.Button.MouseButton1Down:connect(function()
- Clicked = true
- repeat
- Density.Button.Position = UDim2.new(0,math.clamp(mouse.x - Density.AbsolutePosition.x - 8,-8,122),0,-8)
- DValue = math.floor(math.clamp(((Density.Button.Position.X.Offset + 8)/130)+.25,.25,1) * 25)
- Sphere.Transparency = (2 - DValue)/2
- Gui.Frame1.Frame.Density.Text = "Density: ".. DValue
- wait()
- until Clicked == false
- end)
- Size.Button.MouseButton1Up:connect(function()
- if Clicked then
- Clicked = false
- end
- end)
- Density.Button.MouseButton1Up:connect(function()
- if Clicked then
- Clicked = false
- end
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement