vlatkovski

Example Command Bar Code

Feb 11th, 2015
566
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.43 KB | None | 0 0
  1. -------------------------------------------------------
  2. -- Feel free to use samples of this or the whole thing, idc.
  3.  
  4. local create = LoadLibrary("RbxUtility").Create; -- Instance.new utility
  5. local gp = UDim.new; local gp2 = UDim2.new; local c3 = Color3.new; -- Saves typing
  6. local function c255(r,g,b) return c3(r/255, g/255, b/255) end;
  7.  
  8. local me = game.Players.LocalPlayer;
  9. local mouse = me:GetMouse();
  10.  
  11. local commandBarHotkey = ";";
  12.  
  13. -----------------------------------------------------
  14.  
  15. local cmdbarlasttext = "Command Bar";
  16.  
  17. local function MakeGuis()
  18.  
  19.     local cmdbarexecuted = true;
  20.  
  21.     local gui = me.PlayerGui:FindFirstChild("gui") or create "ScreenGui" {
  22.         Parent = me.PlayerGui;
  23.         Name = "gui";
  24.     };
  25.  
  26.     local cmdBarFrame = gui:FindFirstChild("Cmd_Bar") or create "Frame" {
  27.         Parent = gui;
  28.         Name = "Cmd_Bar";
  29.         Position = gp2(1, -300, 1, -100);
  30.         Size = gp2(0, 300, 0, -35);
  31.         Style = Enum.FrameStyle.DropShadow;
  32.         ZIndex = 9;
  33.     };
  34.  
  35.     local cmdBar = cmdBarFrame:FindFirstChild("TB") or create "TextBox" {
  36.         Parent = cmdBarFrame;
  37.         Name = "TB";
  38.         BackgroundTransparency = 1;
  39.         ClearTextOnFocus = false;
  40.         MultiLine = false;
  41.         Position = gp2(0, 0, 0, 0);
  42.         Size = gp2(1, -6, 1, 0);
  43.         ZIndex = 10;
  44.         Font = Enum.Font.SourceSans;
  45.         FontSize = Enum.FontSize.Size24;
  46.         Text = cmdbarlasttext;
  47.         TextColor3 = c3(1, 1, 1);
  48.         TextScaled = false;
  49.         TextWrapped = false;
  50.         TextStrokeColor3 = c255(170, 170, 170);
  51.         TextStrokeTransparency = 0.7;
  52.         TextXAlignment = Enum.TextXAlignment.Right;
  53.     };
  54.  
  55.     cmdBar.FocusLost:connect(function(enterPressed)
  56.         if (enterPressed) then
  57.             local txt = cmdBar.Text
  58.             --------------------------------------
  59.  
  60.             --CODE WHEN ENTER IS PRESSED HERE ;)
  61.             --onChat(txt);
  62.             print(string.format("Command bar executed! (%q)", txt))
  63.            
  64.             --------------------------------------
  65.             cmdbarexecuted = true;
  66.         end
  67.     end)
  68.  
  69.     cmdBar.Changed:connect(function(change)
  70.         if (change ~= "Parent") then
  71.             cmdbarlasttext = cmdBar.Text;
  72.         end
  73.     end)
  74.  
  75.     mouse.KeyDown:connect(function(key)
  76.         if (key == commandBarHotkey) then
  77.             if (cmdbarexecuted == true) then
  78.                 cmdBar.Text = "";
  79.                 cmdbarexecuted = false;
  80.             end
  81.             cmdBar:CaptureFocus();
  82.         end
  83.     end)
  84.  
  85.     return gui;
  86. end
  87.  
  88. MakeGuis()
  89.  
  90.  
  91.  
  92.  
  93. -- roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox roblox
Advertisement
Add Comment
Please, Sign In to add comment