Advertisement
Vzurxy

Untitled

Jul 5th, 2019
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 13.54 KB | None | 0 0
  1. -- @author  / nil (deu)
  2. -- @date    / July 5th, 2019
  3. -- @desc    / binds2
  4.  
  5. --[[
  6.    
  7.     new features in binds2:
  8.     - xray
  9.     - waypoint
  10.     - nodes
  11.     - precise tp
  12.     - delete all build parts
  13.     - undo all deletes
  14.    
  15.     improvements from binds1:
  16.     - cleaner code
  17.     - shift binds
  18.     - plenty o' bug fixes
  19.     - configuration section if you're into that
  20.    
  21.     hope you enjoy o/
  22.    
  23. --]]
  24.  
  25. -- prevents multiple instances of binds2 to be ran
  26. if not _G.binds2init then
  27.  
  28. -- configuration
  29. local binds = {
  30.     ["teleport"] = Enum.KeyCode.T,  -- teleport on top of the part you click on
  31.     ["precise"] = Enum.KeyCode.Y,   -- teleport exactly where you click
  32.     ["attach"] = Enum.KeyCode.F,    -- attach to a player
  33.     ["waypoint"] = Enum.KeyCode.G,  -- creates a waypoint where you're currently standing (shift+G to go to it)
  34.     ["clip"] = Enum.KeyCode.Z,      -- disable collisions with parts
  35.     ["delete"] = Enum.KeyCode.X,    -- click parts to delete them (U to undo)
  36.     ["null"] = Enum.KeyCode.C,      -- default behavior
  37.     ["path"] = Enum.KeyCode.V,      -- click and hold to create a part underneath you
  38.     ["build"] = Enum.KeyCode.B      -- create bricks
  39. }
  40.  
  41. local shift_binds = {
  42.     ["build"] = Enum.KeyCode.B,     -- clear build parts
  43.     ["nodes"] = Enum.KeyCode.N,     -- create/destroy nodes
  44.     ["undoall"] = Enum.KeyCode.U,   -- undo all deletes
  45.     ["waypoint"] = Enum.KeyCode.G,  -- waypoint (teleport to)
  46.     ["delwp"] = Enum.KeyCode.H,     -- deletes waypoint
  47.     ["xray"] = Enum.KeyCode.X       -- xray
  48. }
  49.  
  50. local build_size = Vector3.new(4, 1, 4)
  51. local build_reflectance = 1
  52. local build_color = Color3.fromRGB(160, 160, 160)
  53. local build_material = Enum.Material.SmoothPlastic
  54. local build_transparency = 0
  55.  
  56. local path_size = Vector3.new(8, 1, 8)
  57. local path_material = Enum.Material.SmoothPlastic
  58. local path_transparency = 0
  59. local path_reflectance = 1
  60. local path_color = Color3.fromRGB(160, 160, 160)
  61.  
  62. local xray_transparency = 0.5
  63.  
  64. -- services
  65. local uis = game:GetService("UserInputService")
  66. local ts = game:GetService("TweenService")
  67.  
  68. -- variables
  69. _G.binds2init = true
  70.  
  71. local plr = game.Players.LocalPlayer
  72. local mouse = plr:GetMouse()
  73.  
  74. local mode = "null"
  75.  
  76. local waypoint = nil
  77.  
  78. local noclip = false
  79. local xray = false
  80. local nodes_enabled = false
  81. local shifting = false
  82.  
  83. local no_select = {
  84.     "null", "build", "path", "teleport", "precise"
  85. }
  86.  
  87. local colors = {
  88.     ["null"] = Color3.fromRGB(166, 166, 166),
  89.     ["clip"] = Color3.fromRGB(189, 148, 78),
  90.     ["delete"] = Color3.fromRGB(189, 102, 102),
  91.     ["build"] = Color3.fromRGB(133, 172, 189),
  92.     ["path"] = Color3.fromRGB(81, 78, 189),
  93.     ["teleport"] = Color3.fromRGB(225, 133, 255),
  94.     ["precise"] = Color3.fromRGB(225, 133, 255),
  95.     ["attach"] = Color3.fromRGB(80, 255, 162),
  96.     ["waypoint"] = Color3.fromRGB(29, 157, 255),
  97.     ["nodes"] = Color3.fromRGB(142, 255, 116)
  98. }
  99.  
  100. local f = Instance.new("Folder", game.Workspace)
  101. local fb = Instance.new("Folder", f)
  102. f.Name = "binds2"
  103. fb.Name = "build_parts"
  104.  
  105. local deleted = {}
  106.  
  107. local del = Instance.new("Folder", game.ReplicatedStorage)
  108. del.Name = "binds2_deleted"
  109.  
  110. local attached = nil
  111. local attaching = false
  112.  
  113. local s = Instance.new("SelectionBox", f)
  114. s.Name = "select"
  115. s.Color3 = colors[mode]
  116. s.LineThickness = 0.03
  117. s.Transparency = 0.3
  118.  
  119. -- functions
  120. init = function()
  121.     local sg = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui)
  122.     sg.Name = "binds2"
  123.     sg.ResetOnSpawn = false
  124.     sg.DisplayOrder = 100
  125.    
  126.     local main = Instance.new("Frame", sg)
  127.     main.Name = "main"
  128.     main.AnchorPoint = Vector2.new(0, 1)
  129.     main.Position = UDim2.new(0, 15, 1, -15)
  130.     main.BackgroundTransparency = 1
  131.     main.Size = UDim2.new(0, 250, 0, 16)
  132.    
  133.     local label = Instance.new("TextLabel", main)
  134.     label.Name = "label"
  135.     label.Text = "mode:"
  136.     label.BackgroundTransparency = 1
  137.     label.Font = Enum.Font.SourceSansBold
  138.     label.TextColor3 = Color3.fromRGB(255, 255, 255)
  139.     label.TextStrokeTransparency = 0.8
  140.     label.TextScaled = true
  141.     label.Size = UDim2.new(0, 39, 1, 0)
  142.     label.TextXAlignment = Enum.TextXAlignment.Left
  143.    
  144.     local ml = Instance.new("TextLabel", main)
  145.     ml.Name = "mode"
  146.     ml.Text = mode
  147.     ml.BackgroundTransparency = 1
  148.     ml.TextColor3 = colors[mode]
  149.     ml.Font = Enum.Font.SourceSansBold
  150.     ml.TextStrokeTransparency = 0.8
  151.     ml.TextScaled = true
  152.     ml.Position = UDim2.new(0, 42, 0, 0)
  153.     ml.Size = UDim2.new(1, -42, 1, 0)
  154.     ml.TextXAlignment = Enum.TextXAlignment.Left
  155.    
  156.     print("[binds2] initialized")
  157. end
  158.  
  159. createNode = function(user, class)
  160.     local b = Instance.new("BillboardGui")
  161.     b.Name = "node"
  162.     b.LightInfluence = 0
  163.     b.Size = UDim2.new(4, 0, 1, 0)
  164.     b.ZIndexBehavior = Enum.ZIndexBehavior.Global
  165.     b.AlwaysOnTop = true
  166.     b.Parent = user
  167.    
  168.     if class == "nodes" and user:IsA("Player") then
  169.         b.Parent = user.Character.HumanoidRootPart
  170.     end
  171.    
  172.     local m = Instance.new("Frame", b)
  173.     m.Name = "main"
  174.     m.Size = UDim2.new(1, 0, 1, 0)
  175.     m.BackgroundTransparency = 1
  176.    
  177.     local i = Instance.new("Frame", m)
  178.     i.Name = "indicator"
  179.     i.BackgroundColor3 = colors[class]
  180.     i.Size = UDim2.new(0, 7, 0, 7)
  181.     i.AnchorPoint = Vector2.new(0.5, 0.5)
  182.     i.Position = UDim2.new(0.5, 0, 0.5, 0)
  183.     i.BorderSizePixel = 0
  184.    
  185.     local l = Instance.new("TextLabel", m)
  186.     l.Name = "label"
  187.     l.TextColor3 = Color3.fromRGB(255, 255, 255)
  188.     l.Font = Enum.Font.SourceSansBold
  189.     l.TextSize = 14
  190.     l.TextStrokeTransparency = 0.6
  191.     l.Size = UDim2.new(1, 0, 1, 0)
  192.     l.AnchorPoint = Vector2.new(0.5, 0.2)
  193.     l.Position = UDim2.new(0.5, 0, 0.5, 0)
  194.     l.BackgroundTransparency = 1
  195.    
  196.        
  197.     if class == "nodes" then
  198.         l.Text = user.Name
  199.     elseif class == "waypoint" then
  200.         l.Text = "waypoint"
  201.     end
  202. end
  203.  
  204. shift = function(task)
  205.     if task == "build" then
  206.         for _,v in pairs(fb:GetChildren()) do
  207.             v:Destroy()
  208.         end
  209.     elseif task == "nodes" then
  210.         if not nodes_enabled then
  211.             for _,v in pairs(game.Players:GetPlayers()) do
  212.                 if v ~= plr then
  213.                     createNode(v, "nodes")
  214.                 end
  215.             end
  216.             nodes_enabled = true
  217.         else
  218.             nodes_enabled = false
  219.             for _,v in pairs(game.Players:GetPlayers()) do
  220.                 if v ~= plr and v.Character:FindFirstChild("HumanoidRootPart") then
  221.                     if v.Character.HumanoidRootPart:FindFirstChild("node") then
  222.                         v.Character.HumanoidRootPart.node:Destroy()
  223.                     end
  224.                 end
  225.             end
  226.         end
  227.     elseif task == "waypoint" then
  228.         if not waypoint then
  229.             local p = Instance.new("Part", f)
  230.             p.Anchored = true
  231.             p.CanCollide = false
  232.             p.Size = Vector3.new(1, 1, 1)
  233.             p.Color = Color3.fromRGB(255, 255, 255)
  234.             p.Material = Enum.Material.Neon
  235.             p.CFrame = plr.Character.HumanoidRootPart.CFrame
  236.            
  237.             createNode(p, "waypoint")
  238.             waypoint = p
  239.         else
  240.             plr.Character.HumanoidRootPart.CFrame = waypoint.CFrame
  241.         end
  242.     elseif task == "delwp" then
  243.         if waypoint then
  244.             waypoint:Destroy()
  245.             waypoint = nil
  246.         end
  247.     elseif task == "xray" then
  248.         search = function(model)
  249.             for _,v in pairs(model:GetChildren()) do
  250.                 if #v:GetChildren() > 0 then
  251.                     search(v)
  252.                 end
  253.                
  254.                 if not v.Parent:FindFirstChild("Humanoid") then
  255.                     if v:IsA("BasePart") and v.CFrame.Y > plr.Character.HumanoidRootPart.CFrame.Y and not v.Parent:IsA("Accessory") and not xray then
  256.                         if not v:FindFirstChild("xrayTransparency") then
  257.                             local ot = Instance.new("NumberValue", v)
  258.                             ot.Name = "xrayTransparency"
  259.                             ot.Value = v.Transparency
  260.                         end
  261.                        
  262.                         v.Transparency = xray_transparency             
  263.                     elseif v:IsA("BasePart") and xray and v:FindFirstChild("xrayTransparency") then
  264.                         v.Transparency = v.xrayTransparency.Value
  265.                         v.xrayTransparency:Destroy()
  266.                     end
  267.                 end
  268.             end
  269.         end
  270.        
  271.         if not xray then
  272.             search(game.Workspace)
  273.             xray = true
  274.         else
  275.             search(game.Workspace)
  276.             xray = false
  277.         end
  278.     elseif task == "undoall" then
  279.         for _,v in pairs(del:GetChildren()) do
  280.             if v:FindFirstChild("bindsParent") then
  281.                 v.Parent = v.bindsParent.Value
  282.                 v.bindsParent:Destroy()
  283.             end
  284.         end
  285.        
  286.         deleted = {}
  287.     end
  288. end
  289.  
  290. update = function(old, new)
  291.     -- updates the ui
  292.     if new ~= "attach" then
  293.         attached = nil
  294.         attaching = false
  295.     end
  296.    
  297.     local label = plr:WaitForChild("PlayerGui").binds2.main.mode
  298.     local twn = ts:Create(label, TweenInfo.new(0.25, Enum.EasingStyle.Sine), {TextColor3 = colors[new]})
  299.     twn:Play()
  300.    
  301.     if new == "precise" then
  302.         label.Text = "precise teleport"
  303.     else
  304.         label.Text = new
  305.     end
  306.    
  307.     mode = new
  308. end
  309.  
  310. -- events
  311. mouse.Button1Down:connect(function()
  312.     local mt = mouse.Target
  313.    
  314.     -- modes that don't require mouse.Target to exist or not
  315.     if mode == "path" then
  316.         if not f:FindFirstChild("path") then
  317.             local p = Instance.new("Part", f)
  318.             p.Name = "path"
  319.             p.Size = path_size
  320.             p.Material = path_material
  321.             p.Transparency = path_transparency
  322.             p.Reflectance = path_reflectance
  323.             p.Color = path_color
  324.             p.Anchored = true
  325.             p.TopSurface = Enum.SurfaceType.Smooth
  326.             p.BottomSurface = Enum.SurfaceType.Smooth
  327.         end
  328.     elseif mode == "waypoint" then
  329.         if not waypoint and plr.Character:FindFirstChild("HumanoidRootPart") then
  330.             local p = Instance.new("Part", f)
  331.             p.Name = "waypoint"
  332.             p.Size = Vector3.new(1, 1, 1)
  333.             p.Anchored = true
  334.             p.CanCollide = false
  335.             p.Material = Enum.Material.Neon
  336.             p.CFrame = plr.Character.HumanoidRootPart.CFrame
  337.            
  338.             createNode(p, "waypoint")
  339.             waypoint = p
  340.         elseif waypoint and f:FindFirstChild("waypoint") and plr.Character:FindFirstChild("HumanoidRootPart") then
  341.             f.waypoint.CFrame = plr.Character.HumanoidRootPart.CFrame
  342.         end
  343.     end
  344.    
  345.     if mt then
  346.         if mode == "clip" then
  347.             if not mt:FindFirstChild("clipTransparency") and not mt:FindFirstChild("collidable") then
  348.                 if not mt:FindFirstChild("xrayTransparency") then
  349.                     local ct = Instance.new("NumberValue", mt)
  350.                     ct.Name = "clipTransparency"
  351.                     ct.Value = mt.Transparency
  352.                 end
  353.                
  354.                 local cv = Instance.new("BoolValue", mt)
  355.                 cv.Name = "collidable"
  356.                 cv.Value = mt.CanCollide
  357.                
  358.                 mt.Transparency = 0.5
  359.                 mt.CanCollide = false
  360.             end
  361.         elseif mode == "delete" then
  362.             -- don't actually delete so it retains all children
  363.             local stv = Instance.new("ObjectValue", mt)
  364.             stv.Name = "bindsParent"
  365.             stv.Value = mt.Parent
  366.            
  367.             table.insert(deleted, #deleted + 1, mt)
  368.             mt.Parent = del
  369.         elseif mode == "build" then
  370.             local p = Instance.new("Part", fb)
  371.             p.Size = build_size
  372.             p.Reflectance = build_reflectance
  373.             p.Color = build_color
  374.             p.Material = build_material
  375.             p.Transparency = build_transparency
  376.             p.Anchored = true
  377.             p.CFrame = mouse.Hit
  378.         elseif mode == "teleport" then
  379.             plr.Character:MoveTo(mouse.Hit.Position)
  380.         elseif mode == "precise" then
  381.             plr.Character:FindFirstChild("HumanoidRootPart").CFrame = mouse.Hit
  382.         elseif mode == "attach" then
  383.             if mt.Parent:FindFirstChild("Humanoid") then
  384.                 attached = mt.Parent
  385.                 attaching = true
  386.             end
  387.         end
  388.     end
  389. end)
  390.  
  391. mouse.Button1Up:connect(function()
  392.     if mode == "path" and f:FindFirstChild("path") then
  393.         f.path:Destroy()
  394.     end
  395. end)
  396.  
  397. mouse.Button2Down:connect(function()
  398.     local mt = mouse.Target
  399.     if mt and mode == "clip" then
  400.         if mt:FindFirstChild("xrayTransparency") or mt:FindFirstChild("clipTransparency") and mt:FindFirstChild("collidable") then
  401.             if mt:FindFirstChild("xrayTransparency") then
  402.                 mt.Transparency = xray_transparency
  403.                 mt.CanCollide = mt.collidable.Value
  404.            
  405.                 mt.collidable:Destroy()
  406.             else
  407.                 mt.Transparency = mt.clipTransparency.Value
  408.                 mt.CanCollide = mt.collidable.Value
  409.                
  410.                 mt.clipTransparency:Destroy()
  411.                 mt.collidable:Destroy()
  412.             end
  413.         end
  414.     end
  415. end)
  416.  
  417. game.Players.PlayerAdded:connect(function(player)
  418.     player.CharacterAdded:connect(function(char)
  419.         spawn(function()
  420.             repeat wait() until char:FindFirstChild("HumanoidRootPart")
  421.             if nodes_enabled then
  422.                 createNode(player, "nodes")
  423.             end
  424.         end)
  425.     end)
  426. end)
  427.  
  428. game.Players.PlayerRemoving:connect(function(player)
  429.     if attached and attaching then
  430.         if attached.Name == player.Name then
  431.             attached = nil
  432.             attaching = false
  433.         end
  434.     end
  435. end)
  436.  
  437. game:GetService("RunService").RenderStepped:connect(function()
  438.     local sel = true
  439.     for _,v in pairs(no_select) do
  440.         if mode == v then
  441.             sel = false
  442.             s.Adornee = nil
  443.         end
  444.     end
  445.    
  446.     if attaching and attached then
  447.         pcall(function()
  448.             plr.Character.HumanoidRootPart.CFrame = attached.HumanoidRootPart.CFrame
  449.         end)
  450.     end
  451.    
  452.     local mt = mouse.Target
  453.     if mt and sel then
  454.         s.Adornee = mouse.Target
  455.         s.Color3 = colors[mode]
  456.     elseif not mt and sel then
  457.         s.Adornee = nil
  458.     end
  459.    
  460.     if mode == "path" then
  461.         if f:FindFirstChild("path") and game.Players.LocalPlayer.Character:FindFirstChild("HumanoidRootPart") then
  462.             pcall(function()
  463.                 f.path.Position = Vector3.new(plr.Character.HumanoidRootPart.Position.X, plr.Character.HumanoidRootPart.Position.Y - 3.1, plr.Character.HumanoidRootPart.Position.Z)
  464.             end)
  465.         end
  466.     end
  467. end)
  468.  
  469. uis.InputBegan:connect(function(input, gpe)
  470.     if not gpe and input.UserInputType == Enum.UserInputType.Keyboard then
  471.         if input.KeyCode == Enum.KeyCode.LeftShift then
  472.             shifting = true
  473.         elseif input.KeyCode == Enum.KeyCode.U and not shifting then
  474.             if #deleted >= 1 and deleted[#deleted]:FindFirstChild("bindsParent") then
  475.                 deleted[#deleted].Parent = deleted[#deleted].bindsParent.Value
  476.                 deleted[#deleted].bindsParent:Destroy()
  477.                 table.remove(deleted, #deleted)
  478.             end
  479.         else
  480.             if shifting then
  481.                 for i,v in pairs(shift_binds) do
  482.                     if input.KeyCode == v then
  483.                         shift(i)
  484.                     end
  485.                 end
  486.             else
  487.                 for i,v in pairs(binds) do
  488.                     if input.KeyCode == v then
  489.                         update(mode, i)
  490.                     end
  491.                 end
  492.             end
  493.         end
  494.     end
  495. end)
  496.  
  497. uis.InputEnded:connect(function(input, gpe)
  498.     if not gpe and input.UserInputType == Enum.UserInputType.Keyboard then
  499.         if input.KeyCode == Enum.KeyCode.LeftShift then
  500.             if shifting then
  501.                 shifting = false
  502.             end
  503.         end
  504.     end
  505. end)
  506.  
  507. init()
  508.  
  509. end -- don't delete me!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement