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 ExpandButton = Instance.new('TextButton') ExpandButton.Text = '展开' ExpandButton.Size = UDim2.new(0, 50, 0, 30) ExpandButton.Position = UDim2.new(0, 0, 0, 10) ExpandButton.Parent = ScreenGui

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

-- 将其他UI设置为不可见 local function HideUI() for _, child in ipairs(ScreenGui:GetChildren()) do if child ~= HiddenFrame and child ~= ExpandButton then child.Visible = false end end end

-- 将其他UI设置为可见 local function ShowUI() for _, child in ipairs(ScreenGui:GetChildren()) do if child ~= HiddenFrame and child ~= ExpandButton then child.Visible = true end end end

-- 点击展开按钮,隐藏UI消失,其他UI不可见,展开按钮变成隐藏按钮 ExpandButton.MouseButton1Click:Connect(function() HiddenFrame:TweenPosition(UDim2.new(0.5, -50, 0.5, -25), 'InOut', 'Quad', 0.5) HideUI() ExpandButton.Text = '隐藏' end)

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

-- 点击隐藏按钮,隐藏UI出现,其他UI可见,隐藏按钮变成展开按钮 HideButton.MouseButton1Click:Connect(function() HiddenFrame:TweenPosition(UDim2.new(-1, 0, 0.5, -25), 'InOut', 'Quad', 0.5) ShowUI() ExpandButton.Text = '展开' end)

-- 添加播放器脚本 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)

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

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

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

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