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
- -- ugly code
- function lib:NewWindow(name)
- if not plr.PlayerGui:FindFirstChild("ui") then
- local parent = Instance.new("ScreenGui", plr.PlayerGui)
- 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 = plr.PlayerGui.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 = plr.PlayerGui.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 val.Value >= 4 then
- plr:Kick("UI LIBRARY: Too many objects in one gui, the max is 3.")
- end
- 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
- return lib
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement