Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Ahxyz#0144 // Project Insurgent QuickMenu API
- --[[
- This is just a quick API i put together to test functions with ease. The syntax is as follows:
- local module = loadstring(game:HttpGet("https://pastebin.com/raw/iU43kUrL",true))()
- > This will load in the code below as a module.
- Module:Init(string Name)
- > This will initialise the API for building.
- local mymenu = module:NewMenu{string Name=None}
- > Create a menu object
- mymenu:AddToggle(string Name,function Callback)
- > Adds a togglable switch to the menu object. the Callback function will be called when the switch toggled, and will return (bool
- ToggleStatus).
- mymenu:AddButton(string Name,function Callback)
- > Adds a clickable button to the menu object. The Callback function will be called when the button is pressed, and will not return
- any values.
- mymenu:AddDivider()
- > Adds a line after the last object.
- mymenu:AddTextLabel(string Name)
- > Adds a text label with Name as Text.
- mymenu:AddTextBox(string Name,string Hint,function Callback)
- > Adds a text input box to the menu object. Hint is PlaceholderText. The callback function will be called when the
- TextBox.FocusLost event fires, and will return (string Text).
- mymenu:Build()
- > Builds the menu and runs it's neccessary scripts.
- module:Finalise()
- > Shows the GUI on the user's screen.
- Other Functions:
- menuobject = mymenu:Find(string ObjectName)
- > This will find the first object with the provided name in the menu and return it's data table.
- --]]
- local MAIN_Module = {}
- local MAIN_Enum = {
- ["TogglePos"] = {
- ["On"] = UDim2.new(0.5,0,0,0),
- ["Off"] = UDim2.new(0,0,0,0)
- }
- }
- -- Internal Functions
- local MAIN_New = {}
- function MAIN_New:Menu(Parent,Pos,Name)
- local Menu = Instance.new("Frame")
- local Topbar = Instance.new("Frame")
- local Background = Instance.new("ImageLabel")
- local Title = Instance.new("TextLabel")
- local Minimise = Instance.new("TextButton")
- Menu.Name = Name
- Menu.Parent = Parent
- Menu.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
- Menu.BorderSizePixel = 0
- Menu.ClipsDescendants = true
- Menu.Position = Pos
- Menu.Size = UDim2.new(0, 150, 0, 60)
- Topbar.Name = "Topbar"
- Topbar.Parent = Menu
- Topbar.BackgroundColor3 = Color3.fromRGB(55, 55, 55)
- Topbar.BorderSizePixel = 0
- Topbar.ClipsDescendants = true
- Topbar.Position = UDim2.new(0, 0, -0.00333333015, 0)
- Topbar.Size = UDim2.new(0, 150, 0, 25)
- Background.Name = "Background"
- Background.Parent = Topbar
- Background.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- Background.BackgroundTransparency = 1.000
- Background.BorderSizePixel = 0
- Background.Position = UDim2.new(0, 0, -0.959999979, 0)
- Background.Size = UDim2.new(0, 150, 0, 84)
- Title.Name = "Title"
- Title.Parent = Topbar
- Title.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- Title.BackgroundTransparency = 1.000
- Title.BorderSizePixel = 0
- Title.Position = UDim2.new(0.266666681, 0, 0, 0)
- Title.Size = UDim2.new(0, 69, 0, 24)
- Title.Font = Enum.Font.SourceSansBold
- Title.Text = Name
- Title.TextColor3 = Color3.fromRGB(230, 230, 230)
- Title.TextSize = 14.000
- Minimise.Name = "Minimise"
- Minimise.Parent = Topbar
- Minimise.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- Minimise.BackgroundTransparency = 1.000
- Minimise.BorderSizePixel = 0
- Minimise.Position = UDim2.new(0.866666675, 0, 0.00800048839, 0)
- Minimise.Size = UDim2.new(0, 20, 0, 23)
- Minimise.Font = Enum.Font.SourceSans
- Minimise.Text = "-"
- Minimise.TextColor3 = Color3.fromRGB(255, 255, 255)
- Minimise.TextSize = 14.000
- Minimise.AutoButtonColor = false
- return {
- ["Name"] = Name,
- ['Self'] = Menu,
- ['Topbar'] = Topbar,
- ['Background'] = Background,
- ['Title'] = Title,
- ['Minimise'] = Minimise
- }
- end
- function MAIN_New:Toggle(Parent,Pos,Text)
- local Switch = Instance.new("Frame")
- local Toggle = Instance.new("TextButton")
- local SwitchLabel = Instance.new("TextLabel")
- Switch.Name = Text
- Switch.Parent = Parent
- Switch.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
- Switch.BorderColor3 = Color3.fromRGB(100, 100, 100)
- Switch.Position = Pos
- Switch.Size = UDim2.new(0, 30, 0, 10)
- Toggle.Name = "Toggle"
- Toggle.Parent = Switch
- Toggle.BackgroundColor3 = Color3.fromRGB(240, 240, 240)
- Toggle.BorderSizePixel = 0
- Toggle.Position = UDim2.new(0.5, 0, -3.81469732e-07, 0)
- Toggle.Size = UDim2.new(0, 15, 0, 10)
- Toggle.Font = Enum.Font.SourceSans
- Toggle.Text = ""
- Toggle.TextColor3 = Color3.fromRGB(0, 0, 0)
- Toggle.TextSize = 14.000
- Toggle.AutoButtonColor = false
- SwitchLabel.Name = "SwitchLabel"
- SwitchLabel.Parent = Switch
- SwitchLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- SwitchLabel.BackgroundTransparency = 1.000
- SwitchLabel.BorderSizePixel = 0
- SwitchLabel.Position = UDim2.new(-3.26666665, 0, 0, 0)
- SwitchLabel.Size = UDim2.new(0, 98, 0, 10)
- SwitchLabel.Font = Enum.Font.SourceSans
- SwitchLabel.Text = Text
- SwitchLabel.TextColor3 = Color3.fromRGB(210, 210, 210)
- SwitchLabel.TextSize = 14.000
- SwitchLabel.TextXAlignment = Enum.TextXAlignment.Left
- return {
- ["Name"] = Text,
- ["Label"] = SwitchLabel,
- ["Self"] = Switch,
- ["Button"] = Toggle
- }
- end
- function MAIN_New:Button(Parent,Pos,Text)
- local Button = Instance.new("Frame")
- local Press = Instance.new("TextButton")
- local ButtonLabel = Instance.new("TextLabel")
- Button.Name = Text
- Button.Parent = Parent
- Button.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
- Button.BorderColor3 = Color3.fromRGB(100, 100, 100)
- Button.Position = Pos
- Button.Size = UDim2.new(0, 30, 0, 10)
- Press.Name = "Press"
- Press.Parent = Button
- Press.BackgroundColor3 = Color3.fromRGB(240, 240, 240)
- Press.BorderSizePixel = 0
- Press.Size = UDim2.new(0, 30, 0, 10)
- Press.Font = Enum.Font.SourceSans
- Press.Text = ""
- Press.TextColor3 = Color3.fromRGB(0, 0, 0)
- Press.TextSize = 14.000
- Press.AutoButtonColor = false
- ButtonLabel.Name = "ButtonLabel"
- ButtonLabel.Parent = Button
- ButtonLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- ButtonLabel.BackgroundTransparency = 1.000
- ButtonLabel.BorderSizePixel = 0
- ButtonLabel.Position = UDim2.new(-3.26666665, 0, 0, 0)
- ButtonLabel.Size = UDim2.new(0, 98, 0, 10)
- ButtonLabel.Font = Enum.Font.SourceSans
- ButtonLabel.Text = Text
- ButtonLabel.TextColor3 = Color3.fromRGB(210, 210, 210)
- ButtonLabel.TextSize = 14.000
- ButtonLabel.TextXAlignment = Enum.TextXAlignment.Left
- return {
- ["Name"] = Text,
- ["Label"] = ButtonLabel,
- ["Self"] = Button,
- ["Button"] = Press
- }
- end
- function MAIN_New:Divider(Parent,Pos)
- local Divider = Instance.new("Frame")
- Divider.Name = "Divider"
- Divider.Parent = Parent
- Divider.BackgroundColor3 = Color3.fromRGB(230, 230, 230)
- Divider.BorderSizePixel = 0
- Divider.Position = Pos
- Divider.Size = UDim2.new(0, 128, 0, 1)
- return {
- ["Name"] = "Divider",
- ["Self"] = Divider
- }
- end
- function MAIN_New:TextLabel(Parent,Pos,Text)
- local TextLabel = Instance.new("TextLabel")
- TextLabel.Name = Text:sub(1,7).."..."
- TextLabel.Parent = Parent
- TextLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- TextLabel.BackgroundTransparency = 1.000
- TextLabel.BorderSizePixel = 0
- TextLabel.Position = Pos
- TextLabel.Size = UDim2.new(0, 128, 0, 15)
- TextLabel.Font = Enum.Font.SourceSans
- TextLabel.Text = Text
- TextLabel.TextColor3 = Color3.fromRGB(245, 245, 245)
- TextLabel.TextSize = 14.000
- return {
- ["Name"] = Text,
- ["Self"] = TextLabel
- }
- end
- function MAIN_New:TextBox(Parent,Pos,Text,Hint)
- local TextBox = Instance.new("TextBox")
- TextBox.Parent = Parent
- TextBox.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- TextBox.BackgroundTransparency = 1.000
- TextBox.BorderSizePixel = 0
- TextBox.Position = Pos
- TextBox.Size = UDim2.new(0, 128, 0, 15)
- TextBox.Font = Enum.Font.SourceSans
- TextBox.PlaceholderColor3 = Color3.fromRGB(140, 140, 140)
- TextBox.PlaceholderText = Hint
- TextBox.Text = Text
- TextBox.TextColor3 = Color3.fromRGB(220, 220, 220)
- TextBox.TextSize = 14.000
- return {
- ["Name"] = Text,
- ["Self"] = TextBox
- }
- end
- -- Variables
- local Base
- local Menus = 0
- -- Module Functions
- function MAIN_Module:Init(Name)
- Base = Instance.new("ScreenGui")
- Base.Name = Name
- Base.Enabled = false
- end
- function MAIN_Module:NewMenu(Argument)
- -- Internal Variables
- local MenuLength = 60
- local ObjectCount = 0
- local DividerCount = 0
- local This = { ["Name"] = Argument.Name, ["UI"] = nil, ["Objects"] = {} }
- -- Create the menu assets
- This.UI = MAIN_New:Menu(Base,UDim2.new(0.02+(Menus/12),0,0.02,0),This.Name)
- Menus = Menus + 1
- -- Draggability
- local DragProperties = {
- ["Dragging"] = false,
- ["Input"] = nil,
- ["DragStart"] = nil,
- ["StartPos"] = nil,
- ["Delta"] = nil
- }
- local function update(input)
- DragProperties.Delta = input.Position - DragProperties.DragStart
- This.UI.Self.Position = UDim2.new(DragProperties.StartPos.X.Scale, DragProperties.StartPos.X.Offset + DragProperties.Delta.X, DragProperties.StartPos.Y.Scale, DragProperties.StartPos.Y.Offset + DragProperties.Delta.Y)
- end
- This.UI.Topbar.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 then
- DragProperties.Dragging = true
- DragProperties.DragStart = input.Position
- DragProperties.StartPos = This.UI.Self.Position
- input.Changed:Connect(function()
- if input.UserInputState == Enum.UserInputState.End then
- DragProperties.Dragging = false
- end
- end)
- end
- end)
- This.UI.Topbar.InputChanged:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then
- DragProperties.Input = input
- end
- end)
- game:GetService("UserInputService").InputChanged:Connect(function(input)
- if input == DragProperties.Input and DragProperties.Dragging then
- update(input)
- end
- end)
- -- Menu General Functions
- function This:Find(Name)
- for i,v in pairs(This.Objects) do
- if v.Name == Name then
- return v
- end
- end
- return nil
- end
- -- Menu Build Functions
- function This:AddToggle(Name,Callback)
- MenuLength = MenuLength + 18
- local Toggle = {
- ["Name"] = Name,
- ["UI"] = nil,
- ["Toggled"] = false
- }
- Toggle["Opfn"] = function()
- Toggle.UI = MAIN_New:Toggle(This.UI.Self,UDim2.new(0.725,0,0,0.4+(18 * (ObjectCount+1))),Name)
- Toggle.UI.Button.Position = MAIN_Enum.TogglePos.Off
- coroutine.resume(coroutine.create(function()
- local Last = false
- while wait() do
- if Toggle.Toggled ~= Last then
- if Toggle.Toggled == true then
- Toggle.UI.Button:TweenPosition(MAIN_Enum.TogglePos.On,Enum.EasingDirection.In,Enum.EasingStyle.Sine,0.2)
- elseif Toggle.Toggled == false then
- Toggle.UI.Button:TweenPosition(MAIN_Enum.TogglePos.Off,Enum.EasingDirection.Out,Enum.EasingStyle.Sine,0.2)
- end
- Last = Toggle.Toggled
- end
- end
- end))
- Toggle.UI.Button.MouseButton1Click:Connect(function()
- Toggle.Toggled = not Toggle.Toggled
- local Ran,Error = pcall(function() Callback(Toggle.Toggled) end)
- if not Ran then
- warn('QuickMenu: Ignoring callback failure: '..Error)
- end
- local Clr = 240
- for _ = 1,5 do
- Clr = Clr - 20
- Toggle.UI.Button.BackgroundColor3 = Color3.fromRGB(Clr,Clr,Clr)
- wait()
- end
- for _ = 1,10 do
- Clr = Clr + 10
- Toggle.UI.Button.BackgroundColor3 = Color3.fromRGB(Clr,Clr,Clr)
- wait()
- end
- end)
- end
- table.insert(This.Objects,Toggle)
- end
- function This:AddButton(Name,Callback)
- MenuLength = MenuLength + 18
- local Button = {
- ["Name"] = Name,
- ["UI"] = nil
- }
- Button["Opfn"] = function()
- Button.UI = MAIN_New:Button(This.UI.Self,UDim2.new(0.725,0,0,0.4+(18 * (ObjectCount+1))),Name)
- Button.UI.Button.MouseButton1Click:Connect(function()
- local Ran,Error = pcall(function() Callback() end)
- if not Ran then
- warn('QuickMenu: Ignoring callback failure: '..Error)
- end
- local Clr = 240
- for _ = 1,5 do
- Clr = Clr - 20
- Button.UI.Button.BackgroundColor3 = Color3.fromRGB(Clr,Clr,Clr)
- wait()
- end
- for _ = 1,10 do
- Clr = Clr + 10
- Button.UI.Button.BackgroundColor3 = Color3.fromRGB(Clr,Clr,Clr)
- wait()
- end
- end)
- end
- table.insert(This.Objects,Button)
- end
- function This:AddDivider()
- MenuLength = MenuLength + 18
- DividerCount = DividerCount + 1
- local Divider = {
- ["Name"] = "Divider"..tostring(DividerCount),
- ["UI"] = nil
- }
- Divider["Opfn"] = function()
- Divider.UI = MAIN_New:Divider(This.UI.Self,UDim2.new(0.065,0,0,6.4+(18 * (ObjectCount+1))))
- end
- table.insert(This.Objects,Divider)
- end
- function This:AddTextLabel(Name)
- MenuLength = MenuLength + 18
- local TextLabel = {
- ["Name"] = Name,
- ["Text"] = Name,
- ["UI"] = nil
- }
- TextLabel["Opfn"] = function()
- TextLabel.UI = MAIN_New:TextLabel(This.UI.Self,UDim2.new(0.065,0,0,-4+(18*(ObjectCount+1))),Name)
- coroutine.resume(coroutine.create(function()
- local Last = ""
- while wait() do
- if Last ~= TextLabel.Text then
- TextLabel.UI.Self.Text = TextLabel.Text
- Last = TextLabel.Text
- end
- end
- end))
- end
- table.insert(This.Objects,TextLabel)
- end
- function This:AddTextBox(Name,Hint,Callback)
- MenuLength = MenuLength + 18
- local TextBox = {
- ["Name"] = Name,
- ["Text"] = "",
- ["Hint"] = Hint,
- ["UI"] = nil
- }
- TextBox["Opfn"] = function()
- TextBox.UI = MAIN_New:TextBox(This.UI.Self,UDim2.new(0.065,0,0,-4+(18*(ObjectCount+1))),Name,Hint)
- coroutine.resume(coroutine.create(function()
- local LastText = TextBox.Text
- local LastHint = TextBox.Hint
- while wait() do
- if LastText ~= TextBox.Text then
- TextBox.UI.Self.Text = TextBox.Text
- LastText = TextBox.Text
- end
- if LastHint ~= TextBox.Hint then
- TextBox.UI.Self.PlaceholderText = TextBox.Hint
- LastHint = TextBox.Hint
- end
- end
- end))
- TextBox.UI.Self.FocusLost:Connect(function()
- local Ran,Error = pcall(function() Callback(TextBox.UI.Self.Text) end)
- if not Ran then
- warn('QuickMenu: Ignoring callback failure: '..Error)
- end
- end)
- end
- table.insert(This.Objects,TextBox)
- end
- function This:Build()
- This.UI.Self.Size = UDim2.new(0,This.UI.Self.Size.X.Offset,0,MenuLength)
- for i,v in pairs(This.Objects) do
- ObjectCount = ObjectCount + 1
- v.Opfn()
- end
- local MenuOpen = true
- local MenuCycling = false
- This.UI.Minimise.MouseButton1Click:Connect(function()
- if MenuCycling == false then
- if MenuOpen then
- MenuCycling = true
- This.UI.Self:TweenSize(UDim2.new(0,150,0,25),Enum.EasingDirection.Out,Enum.EasingStyle.Sine,1)
- This.UI.Minimise.Text = "+"
- wait(1)
- MenuOpen = false
- MenuCycling = false
- else
- local MenuCycling = true
- This.UI.Self:TweenSize(UDim2.new(0,150,0,MenuLength),Enum.EasingDirection.Out,Enum.EasingStyle.Sine,1)
- This.UI.Minimise.Text = "-"
- wait(1)
- MenuOpen = true
- MenuCycling = false
- end
- end
- end)
- end
- return This
- end
- function MAIN_Module:Finalise()
- Base.Parent = game.CoreGui
- Base.Enabled = true
- game:GetService("UserInputService").InputBegan:Connect(function()
- if game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.RightControl) then
- Base.Enabled = not Base.Enabled
- end
- end)
- end
- return MAIN_Module
Add Comment
Please, Sign In to add comment