-- 创建一个屏幕GUI对象local ScreenGui = InstancenewScreenGuiScreenGuiName = NotificationGuiScreenGuiParent = gamePlayersLocalPlayerWaitForChildPlayerGui-- 创建UI元素:文本标签、时间显示和两个按钮local TextLabel = InstancenewTex
-- 创建一个屏幕GUI对象 local ScreenGui = Instance.new("ScreenGui") ScreenGui.Name = "NotificationGui" ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild("PlayerGui")
-- 创建UI元素:文本标签、时间显示和两个按钮 local TextLabel = Instance.new("TextLabel") TextLabel.Size = UDim2.new(1, 0, 0.6, 0) TextLabel.Position = UDim2.new(0, 0, 0.1, 0) TextLabel.Text = "这里是通知信息" TextLabel.FontSize = Enum.FontSize.Size24 TextLabel.BackgroundTransparency = 1 -- 将背景透明 TextLabel.Parent = ScreenGui
local TimeLabel = Instance.new("TextLabel") TimeLabel.Size = UDim2.new(1, 0, 0.2, 0) TimeLabel.Position = UDim2.new(0, 0, 0.7, 0) TimeLabel.FontSize = Enum.FontSize.Size18 TimeLabel.BackgroundTransparency = 1 -- 将背景透明 TimeLabel.Parent = ScreenGui
local OkButton = Instance.new("TextButton") OkButton.Size = UDim2.new(0.2, 0, 0.1, 0) OkButton.Position = UDim2.new(0.2, 0, 0.9, 0) OkButton.Text = "ok" OkButton.Parent = ScreenGui
local NoButton = Instance.new("TextButton") NoButton.Size = UDim2.new(0.2, 0, 0.1, 0) NoButton.Position = UDim2.new(0.6, 0, 0.9, 0) NoButton.Text = "no" NoButton.Parent = ScreenGui
-- 创建功能脚本 local function onOkButtonClicked() -- 在此添加您想要执行的ok功能脚本 ScreenGui.Enabled = false -- 关闭通知界面 end
local function onNoButtonClicked() -- 在此添加您想要执行的no功能脚本 ScreenGui.Enabled = false -- 关闭通知界面 end
-- 添加按钮点击事件监听器 OkButton.Activated:Connect(onOkButtonClicked) NoButton.Activated:Connect(onNoButtonClicked)
-- 显示通知界面 ScreenGui.Enabled = true
-- 更新时间显示 while wait(1) do local currentTime = os.time() TimeLabel.Text = "当前时间:" .. os.date("%H:%M:%S", currentTime) end
原文地址: https://www.cveoy.top/t/topic/bC7R 著作权归作者所有。请勿转载和采集!