以下 Roblox Studio 脚本创建了一个可隐藏的音乐播放器 UI,包含文本框、播放按钮、隐藏按钮和脚本,用于控制音乐播放和 UI 可见性。

-- 创建 UI local ScreenGui = Instance.new('ScreenGui') ScreenGui.Name = 'MusicPlayer' local Frame = Instance.new('Frame') Frame.Position = UDim2.new(0.5, -50, 0.5, -25) Frame.Size = UDim2.new(0, 100, 0, 90) Frame.BackgroundColor3 = Color3.new(1, 1, 1) Frame.BackgroundTransparency = 0.5 Frame.Active = true Frame.Draggable = true Frame.Parent = ScreenGui

-- 创建文本框 local TextBox = Instance.new('TextBox') TextBox.Size = UDim2.new(1, -20, 0, 30) TextBox.Position = UDim2.new(0, 10, 0, 10) TextBox.PlaceholderText = '输入音乐代码' TextBox.ClearTextOnFocus = false TextBox.Parent = Frame

-- 创建播放按钮 local PlayButton = Instance.new('TextButton') PlayButton.Text = '播放音乐' PlayButton.Size = UDim2.new(1, -20, 0, 30) PlayButton.Position = UDim2.new(0, 10, 1, -40) PlayButton.Parent = Frame

-- 创建隐藏按钮 local HideButton = Instance.new('TextButton') HideButton.Text = '隐藏UI' HideButton.Size = UDim2.new(1, -20, 0, 30) HideButton.Position = UDim2.new(0, 10, 1, -70) HideButton.Parent = Frame

-- 添加播放器脚本 local MusicPlayer = Instance.new('Sound', game.Workspace) MusicPlayer.Volume = 1 MusicPlayer.Playing = false

PlayButton.MouseButton1Click:Connect(function() local Code = TextBox.Text if Code ~= '' then MusicPlayer.SoundId = 'rbxassetid://'..Code MusicPlayer:Play() end end)

-- 隐藏所有用户图形界面 local function HideAllGui() for _, player in pairs(game.Players:GetPlayers()) do local playerGui = player:FindFirstChild('PlayerGui') if playerGui then playerGui.Enabled = false end end end

-- 显示所有用户图形界面 local function ShowAllGui() for _, player in pairs(game.Players:GetPlayers()) do local playerGui = player:FindFirstChild('PlayerGui') if playerGui then playerGui.Enabled = true end end end

-- 点击隐藏按钮时隐藏所有用户图形界面 HideButton.MouseButton1Click:Connect(function() HideAllGui() end)

-- 点击其他地方时显示所有用户图形界面 ScreenGui.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 then ShowAllGui() end end)

ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild('PlayerGui')

Roblox Studio: 创建可隐藏的音乐播放器 UI

原文地址: https://www.cveoy.top/t/topic/nar4 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录