Advertisement
NiceBBMBThai

Test UI

Dec 24th, 2024 (edited)
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.39 KB | None | 0 0
  1. local TweenService = game:GetService("TweenService")
  2.  
  3. local UILibrary = {}
  4.  
  5. function UILibrary:CreateMainButton(parent)
  6.     local mainButton = Instance.new("ImageButton")
  7.     mainButton.Name = "Ico_Main"
  8.     mainButton.Parent = parent
  9.     mainButton.Size = UDim2.new(0, 100, 0, 100)
  10.     mainButton.Position = UDim2.new(0.5, -50, 0.5, 300)
  11.     mainButton.AnchorPoint = Vector2.new(0.5, 0.5)
  12.     mainButton.Image = "rbxassetid://96280508973284"
  13.     mainButton.BackgroundTransparency = 1
  14.  
  15.     -- เพิ่ม UICorner
  16.     local corner = Instance.new("UICorner")
  17.     corner.CornerRadius = UDim.new(1, 0)
  18.     corner.Parent = mainButton
  19.  
  20.     return mainButton
  21. end
  22.  
  23. function UILibrary:CreateIcon(parent, name, imageId, position)
  24.     local icon = Instance.new("ImageLabel")
  25.     icon.Name = name
  26.     icon.Parent = parent
  27.     icon.Size = UDim2.new(0, 80, 0, 80)
  28.     icon.Position = position
  29.     icon.AnchorPoint = Vector2.new(0.5, 0.5)
  30.     icon.Image = imageId
  31.     icon.BackgroundTransparency = 1
  32.     icon.Visible = false
  33.  
  34.     -- เพิ่ม UICorner
  35.     local corner = Instance.new("UICorner")
  36.     corner.CornerRadius = UDim.new(1, 0)
  37.     corner.Parent = icon
  38.  
  39.     return icon
  40. end
  41.  
  42. function UILibrary:ToggleIcons(icons, show)
  43.     for _, icon in ipairs(icons) do
  44.         if show then
  45.             icon.Visible = true
  46.             -- Animation แสดง
  47.             icon.Position = icon.Position + UDim2.new(0, 0, 0.2, 0)
  48.             TweenService:Create(icon, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
  49.                 Position = icon.Position - UDim2.new(0, 0, 0.2, 0),
  50.             }):Play()
  51.         else
  52.             -- Animation ซ่อน
  53.             TweenService:Create(icon, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
  54.                 Position = icon.Position + UDim2.new(0, 0, 0.2, 0),
  55.             }):Play()
  56.             task.wait(0.5) -- รอให้ Animation จบก่อน
  57.             icon.Visible = false
  58.         end
  59.     end
  60. end
  61.  
  62. function UILibrary:CreateMainUI()
  63.     -- สร้างหน้าจอหลัก
  64.     local gui = Instance.new("ScreenGui", game.Players.LocalPlayer.PlayerGui)
  65.     gui.Name = "MainUI"
  66.  
  67.     -- สร้างปุ่มหลัก Ico_Main
  68.     local mainButton = self:CreateMainButton(gui)
  69.  
  70.     -- สร้างปุ่มไอคอน (ChatBox, House, Setting)
  71.     local chatBox = self:CreateIcon(mainButton, "ChatBox", "rbxassetid://1234567890", UDim2.new(0.5, 0, 0, -80))
  72.     local house = self:CreateIcon(mainButton, "House", "rbxassetid://1234567891", UDim2.new(0.5, 0, 0, -160))
  73.     local setting = self:CreateIcon(mainButton, "Setting", "rbxassetid://1234567892", UDim2.new(0.5, 0, 0, -240))
  74.  
  75.     -- ซ่อนปุ่มอื่นๆ เริ่มต้น
  76.     chatBox.Visible = false
  77.     house.Visible = false
  78.     setting.Visible = false
  79.  
  80.     -- สร้าง MainHouse
  81.     local mainHouse = self:CreateHouseUI(gui)
  82.  
  83.     -- เพิ่มการคลิกที่ปุ่ม Ico_Main
  84.     mainButton.MouseButton1Click:Connect(function()
  85.         local showIcons = not chatBox.Visible -- สลับสถานะการแสดงผล
  86.         self:ToggleIcons({chatBox, house, setting}, showIcons)
  87.     end)
  88.  
  89.     -- เพิ่มการคลิกที่ Ico_House
  90.     house.MouseButton1Click:Connect(function()
  91.         local showHouse = not mainHouse.Visible -- สลับสถานะ MainHouse
  92.         self:ToggleHouseUI(mainHouse, showHouse)
  93.     end)
  94.  
  95.     -- Animation แสดง Ico_Main
  96.     mainButton.Position = UDim2.new(0.5, 0, 0.5, 300)
  97.     TweenService:Create(mainButton, TweenInfo.new(1, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
  98.         Position = UDim2.new(0.5, 0, 0.5, 0),
  99.     }):Play()
  100. end
  101.  
  102.  
  103. function UILibrary:CreateHouseUI(parent)
  104.     local houseFrame = Instance.new("Frame")
  105.     houseFrame.Name = "MainHouse"
  106.     houseFrame.Parent = parent
  107.     houseFrame.Size = UDim2.new(0, 400, 0, 300)
  108.     houseFrame.Position = UDim2.new(0.5, 0, 0.5, 0)
  109.     houseFrame.AnchorPoint = Vector2.new(0.5, 0.5)
  110.     houseFrame.BackgroundColor3 = Color3.fromRGB(36, 36, 36)
  111.     houseFrame.Visible = false
  112.  
  113.     -- เพิ่ม UICorner
  114.     local corner = Instance.new("UICorner")
  115.     corner.CornerRadius = UDim.new(0.05, 0)
  116.     corner.Parent = houseFrame
  117.  
  118.     -- เพิ่มข้อความใน MainHouse
  119.     local title = Instance.new("TextLabel")
  120.     title.Parent = houseFrame
  121.     title.Size = UDim2.new(1, 0, 0.2, 0)
  122.     title.Position = UDim2.new(0, 0, 0, 0)
  123.     title.BackgroundTransparency = 1
  124.     title.Font = Enum.Font.GothamBold
  125.     title.Text = "Welcome to MainHouse!"
  126.     title.TextColor3 = Color3.fromRGB(255, 255, 255)
  127.     title.TextScaled = true
  128.  
  129.     return houseFrame
  130. end
  131.  
  132. function UILibrary:ToggleHouseUI(houseFrame, show)
  133.     if show then
  134.         houseFrame.Visible = true
  135.         houseFrame.Position = UDim2.new(0.5, 0, 0.7, 0)
  136.         TweenService:Create(houseFrame, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
  137.             Position = UDim2.new(0.5, 0, 0.5, 0),
  138.         }):Play()
  139.     else
  140.         TweenService:Create(houseFrame, TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out), {
  141.             Position = UDim2.new(0.5, 0, 0.7, 0),
  142.         }):Play()
  143.         task.wait(0.5)
  144.         houseFrame.Visible = false
  145.     end
  146. end
  147.  
  148. return UILibrary
  149.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement