Roblox 音乐播放器脚本:隐藏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 = '隐藏' HideButton.Size = UDim2.new(1, -20, 0, 30) HideButton.Position = UDim2.new(0, 10, 1, -80) 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 hideUI() for _, player in pairs(game.Players:GetPlayers()) do if player ~= game.Players.LocalPlayer then local playerGui = player:FindFirstChild('PlayerGui') if playerGui then playerGui.Enabled = false end end end end
-- 显示所有用户图形界面 local function showUI() for _, player in pairs(game.Players:GetPlayers()) do if player ~= game.Players.LocalPlayer then local playerGui = player:FindFirstChild('PlayerGui') if playerGui then playerGui.Enabled = true end end end end
-- 隐藏UI按钮的点击事件 HideButton.MouseButton1Click:Connect(function() hideUI() end)
-- 显示UI按钮的点击事件 Frame.MouseEnter:Connect(function() showUI() end)
ScreenGui.Parent = game.Players.LocalPlayer:WaitForChild('PlayerGui')
原文地址: https://www.cveoy.top/t/topic/nar3 著作权归作者所有。请勿转载和采集!