Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ScriptUI = {}
- function ScriptUI.Frame(Parent)
- local Frame = {}
- Frame.Instance = Instance.new("Frame")
- if Parent then
- Frame.Instance.Parent = Parent
- end
- function Frame:SetSize(Size)
- self.Instance.Size = Size
- return self
- end
- function Frame:SetColor(Color)
- self.Instance.BackgroundColor3 = Color
- return self
- end
- function Frame:SetPosition(Position)
- self.Instance.Position = Position
- return self
- end
- function Frame:SetAnchorPoint(AnchorPoint)
- self.Instance.AnchorPoint = AnchorPoint
- return self
- end
- function Frame:AddChild(Element)
- if typeof(Element) == "Instance" then
- Element.Parent = self.Instance
- elseif typeof(Element) == "table" then
- Element.Instance.Parent = self.Instance
- end
- return self
- end
- function Frame:RemoveChild(Element)
- if typeof(Element) == "Instance" then
- Element:Destroy()
- elseif typeof(Element) == "table" then
- Element.Instance:Destroy()
- end
- return self
- end
- return Frame
- end
- function ScriptUI.Switcher(Parent)
- local Switcher = {}
- Switcher.Parent = nil
- Switcher.Value = false
- Switcher.__debounce__ = false
- Switcher.__debounceDuration__ = 0
- Switcher.Instance = Instance.new("Frame")
- Switcher.Instance.Size = UDim2.new(0.1, 0, 0.1, 0)
- Switcher.Instance.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- if Parent then
- if typeof(Parent) == "Instance" then
- Switcher.Parent = Parent
- Switcher.Instance.Parent = Parent
- elseif typeof(Parent) == "table" then
- Switcher.Parent = Parent
- Switcher.Instance.Parent = Parent.Instance
- end
- end
- local _ = Instance.new("UICorner", Switcher.Instance)
- _.CornerRadius = UDim.new(0, 10)
- local V1 = Instance.new("TextButton", Switcher.Instance)
- V1.Text = ""
- V1.Size = UDim2.new(0.45, 0, 0.8, 0)
- V1.AnchorPoint = Vector2.new(0.5, 0.5)
- V1.Position = UDim2.new(0.275, 0, 0.5, 0)
- V1.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
- V1.MouseButton1Click:Connect(function()
- if not Switcher.__debounce__ then
- Switcher.__debounce__ = true
- if V1.Position == UDim2.new(0.275, 0, 0.5, 0) then
- V1:TweenPosition(UDim2.new(0.725, 0, 0.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Linear, 0.15, true)
- V1.BackgroundColor3 = Color3.new(0, 255, 0)
- Switcher.Value = true
- else
- V1:TweenPosition(UDim2.new(0.275, 0, 0.5, 0), Enum.EasingDirection.InOut, Enum.EasingStyle.Linear, 0.15, true)
- V1.BackgroundColor3 = Color3.new(255, 0, 0)
- Switcher.Value = false
- end
- wait(Switcher.__debounceDuration__)
- Switcher.__debounce__ = false
- end
- end)
- local __ = Instance.new("UICorner", V1)
- __.CornerRadius = UDim.new(0, 10)
- function Switcher:SetSize(Size)
- self.Instance.Size = Size
- return self
- end
- function Switcher:SetPosition(Position)
- self.Instance.Position = Position
- return self
- end
- function Switcher:SetAnchorPoint(AnchorPoint)
- self.Instance.AnchorPoint = AnchorPoint
- return self
- end
- function Switcher:SetDebounceDuration(Duration)
- self.__debounceDuration__ = Duration
- return self
- end
- function Switcher:AddEventListener(Event, Callback)
- if Event == "Switch" then
- local Connection = nil
- Connection = V1.MouseButton1Click:Connect(function()
- Callback(Switcher.Value == false)
- end)
- return self, Connection
- else
- local Connection = nil
- Connection = V1[Event]:Connect(function(...)
- Callback(...)
- end)
- return self, Connection
- end
- end
- return Switcher
- end
- function ScriptUI.TextButton(Text, Parent)
- local Button = {}
- Button.Instance = Instance.new("TextButton")
- Button.Instance.Text = Text
- if Parent then
- Button.Instance.Parent = Parent
- end
- function Button:SetSize(Size)
- self.Instance.Size = Size
- return self
- end
- function Button:SetText(Text)
- self.Instance.Text = Text
- return self
- end
- function Button:SetFont(Font)
- self.Instance.Font = Font
- return self
- end
- function Button:SetFontSize(FontSize)
- self.Instance.TextSize = FontSize
- return self
- end
- function Button:SetColor(Color)
- self.Instance.BackgroundColor3 = Color
- return self
- end
- function Button:SetTextColor(Color)
- self.Instance.TextColor3 = Color
- return self
- end
- function Button:SetPosition(Position)
- self.Instance.Position = Position
- return self
- end
- function Button:SetAnchorPoint(AnchorPoint)
- self.Instance.AnchorPoint = AnchorPoint
- return self
- end
- function Button:AddEventListener(Event, Callback)
- local Connection = nil
- Connection = self.Instance[Event]:Connect(function(...)
- Callback(...)
- end)
- return self, Connection
- end
- return Button
- end
- function ScriptUI.ImageButton(ImageURI, Parent)
- local Button = {}
- Button.Instance = Instance.new("ImageButton")
- Button.Instance.Image = ImageURI
- if Parent then
- Button.Instance.Parent = Parent
- end
- function Button:SetSize(Size)
- self.Instance.Size = Size
- return self
- end
- function Button:SetColor(Color)
- self.Instance.BackgroundColor3 = Color
- return self
- end
- function Button:SetImage(ImageURI)
- self.Instance.Image = ImageURI
- return self
- end
- function Button:SetTextColor(Color)
- self.Instance.TextColor3 = Color
- return self
- end
- function Button:SetPosition(Position)
- self.Instance.Position = Position
- return self
- end
- function Button:SetAnchorPoint(AnchorPoint)
- self.Instance.AnchorPoint = AnchorPoint
- return self
- end
- function Button:AddEventListener(Event, Callback)
- local Connection = nil
- Connection = self.Instance[Event]:Connect(function(...)
- Callback(...)
- end)
- return self, Connection
- end
- return Button
- end
- return ScriptUI
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement