Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local lib = {
- windowcount = 0;
- maxCount = 2;
- maxSideObjects = 2;
- }
- local plrs = game:GetService("Players")
- local plr = plrs.LocalPlayer
- local cui = game:GetService("CoreGui")
- -- ugly code
- function lib:NewWindow(name)
- if not cui:FindFirstChild("ui") then
- local parent = Instance.new("ScreenGui", cui)
- parent.Name = "ui"
- end
- lib.windowcount = lib.windowcount + 1
- if lib.windowcount > lib.maxCount then
- plr:Kick("UI LIBRARY: Maximum window count is "..lib.maxCount)
- end
- local f = Instance.new("Frame")
- f.Name = name
- f.Size = UDim2.new(0,200,0,100)
- f.Parent = cui.ui
- f.Active = true
- f.Draggable = true
- local val = Instance.new("IntValue",f)
- val.Name = "obj"
- val.Value = 0
- local label = Instance.new("TextLabel", f)
- label.Name = "label"
- label.Text = name -- make sure you dont dick off when naming your frames
- label.Position = UDim2.new(0,0,0,0)
- label.Size = UDim2.new(0,200,0,20)
- if lib.windowcount == 1 then
- f.Position = UDim2.new(0,0,0,0)
- elseif lib.windowcount == 2 then
- f.Position = UDim2.new(0.267,0,0,0)
- end
- f.BackgroundColor3 = Color3.new(130,130,130)
- end
- function lib:NewObject(class, name, object)
- local parent = cui.ui:FindFirstChild(object)
- if not parent:FindFirstChild("obj") then
- plr:Kick("LIBRARY: Invalid Parent for object, parent must be a valid frame created by library and have the obj int value in it")
- end
- local val = parent.obj
- val.Value = val.Value + 1
- if class == "ToggleButton" then
- local main = Instance.new("TextButton")
- main.Name = name
- main.Parent = parent
- main.Size = UDim2.new(0,180,0,20)
- main.Text = name..": OFF"
- if val.Value == 1 then
- main.Position = UDim2.new(0.05, 0,0.25, 0)
- elseif val.Value == 2 then
- main.Position = UDim2.new(0.05, 0,0.5, 0)
- elseif val.Value == 3 then
- main.Position = UDim2.new(0.05, 0,0.75, 0)
- end
- local active = Instance.new("BoolValue", main)
- active.Value = false
- active.Name = "on"
- function SCRIPT_PFZT74_FAKESCRIPT() -- TextButton.LocalScript
- local script = Instance.new('LocalScript')
- script.Parent = main
- script.Parent.MouseButton1Click:Connect(function()
- if main.on.Value == true then
- main.on.Value = false
- script.Parent.Text = script.Parent.Name..": OFF"
- else
- main.on.Value = true
- script.Parent.Text = script.Parent.Name..": ON"
- end
- end)
- end
- coroutine.resume(coroutine.create(SCRIPT_PFZT74_FAKESCRIPT))
- end
- if val.Value >= 4 then
- plr:Kick("UI LIBRARY: Too many objects in one gui, the max is 3.")
- end
- if class ~= "ToggleButton" then
- local main = Instance.new(class)
- main.Name = name
- main.Parent = parent
- main.Size = UDim2.new(0,180,0,20)
- main.Text = name
- if val.Value == 1 then
- main.Position = UDim2.new(0.05, 0,0.25, 0)
- elseif val.Value == 2 then
- main.Position = UDim2.new(0.05, 0,0.5, 0)
- elseif val.Value == 3 then
- main.Position = UDim2.new(0.05, 0,0.75, 0)
- end
- end
- end
- return lib
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement