local plr = game.Players.LocalPlayer
local UIS = game:GetService("UserInputService")
local RS = game:GetService("RunService")
local cam = workspace.CurrentCamera
local sound = Instance.new("Sound", cam)
sound.Volume = 0.5
sound.Looped = true
local gui = Instance.new("ScreenGui", plr.PlayerGui)
gui.ResetOnSpawn = false
local main = Instance.new("Frame", gui)
main.Size = UDim2.fromScale(0.34,0.34)
main.Position = UDim2.fromScale(0.33,0.33)
main.BackgroundColor3 = Color3.fromRGB(18,18,22)
main.BorderSizePixel = 0
main.Visible = false
Instance.new("UICorner", main).CornerRadius = UDim.new(0,22)
local shadow = Instance.new("Frame", main)
shadow.Size = UDim2.new(1,14,1,14)
shadow.Position = UDim2.new(0,-7,0,-7)
shadow.BackgroundColor3 = Color3.fromRGB(0,0,0)
shadow.BackgroundTransparency = 0.75
shadow.ZIndex = -1
Instance.new("UICorner", shadow).CornerRadius = UDim.new(0,28)
local header = Instance.new("Frame", main)
header.Size = UDim2.fromScale(1,0.14)
header.BackgroundColor3 = Color3.fromRGB(24,24,30)
header.BorderSizePixel = 0
Instance.new("UICorner", header).CornerRadius = UDim.new(0,22)
local title = Instance.new("TextLabel", header)
title.Size = UDim2.fromScale(1,1)
title.BackgroundTransparency = 1
title.Text = "Music Player"
title.Font = Enum.Font.GothamSemibold
title.TextScaled = true
title.TextColor3 = Color3.fromRGB(230,230,240)
local closeBtn = Instance.new("TextButton", header)
closeBtn.Text = "×"
closeBtn.Size = UDim2.fromScale(0.11,0.75)
closeBtn.Position = UDim2.fromScale(0.88,0.12)
closeBtn.BackgroundColor3 = Color3.fromRGB(70,30,40)
closeBtn.TextColor3 = Color3.fromRGB(255,180,190)
closeBtn.TextScaled = true
Instance.new("UICorner", closeBtn)
local box = Instance.new("TextBox", main)
box.PlaceholderText = "SoundId"
box.Size = UDim2.fromScale(0.9,0.12)
box.Position = UDim2.fromScale(0.05,0.2)
box.BackgroundColor3 = Color3.fromRGB(28,28,36)
box.TextColor3 = Color3.fromRGB(240,240,255)
box.PlaceholderColor3 = Color3.fromRGB(150,150,170)
box.TextScaled = true
box.ClearTextOnFocus = false
Instance.new("UICorner", box)
local function btn(txt,col,pos)
local b = Instance.new("TextButton", main)
b.Text = txt
b.Size = UDim2.fromScale(0.28,0.12)
b.Position = UDim2.fromScale(pos,0.35)
b.BackgroundColor3 = col
b.TextColor3 = Color3.fromRGB(245,245,255)
b.TextScaled = true
b.Font = Enum.Font.GothamMedium
Instance.new("UICorner", b)
return b
end
local play = btn("Play",Color3.fromRGB(90,170,200),0.05)
local pause = btn("Pause",Color3.fromRGB(120,120,200),0.36)
local stop = btn("Stop",Color3.fromRGB(160,90,110),0.67)
local slider = Instance.new("Frame", main)
slider.Size = UDim2.fromScale(0.9,0.055)
slider.Position = UDim2.fromScale(0.05,0.55)
slider.BackgroundColor3 = Color3.fromRGB(35,35,45)
Instance.new("UICorner", slider)
local fill = Instance.new("Frame", slider)
fill.Size = UDim2.fromScale(sound.Volume,1)
fill.BackgroundColor3 = Color3.fromRGB(120,200,220)
Instance.new("UICorner", fill)
local progressBar = Instance.new("Frame", main)
progressBar.Size = UDim2.fromScale(0.9,0.04)
progressBar.Position = UDim2.fromScale(0.05,0.7)
progressBar.BackgroundColor3 = Color3.fromRGB(40,40,55)
Instance.new("UICorner", progressBar)
local progressFill = Instance.new("Frame", progressBar)
progressFill.Size = UDim2.fromScale(0,1)
progressFill.BackgroundColor3 = Color3.fromRGB(180,120,220)
Instance.new("UICorner", progressFill)
RS.RenderStepped:Connect(function()
if sound.IsPlaying and sound.TimeLength > 0 then
progressFill.Size = UDim2.fromScale(math.clamp(sound.TimePosition/sound.TimeLength,0,1),1)
end
end)
play.MouseButton1Click:Connect(function()
local id = tonumber(box.Text)
if id then
sound:Stop()
sound.SoundId = "rbxassetid://"..id
sound:Play()
end
end)
pause.MouseButton1Click:Connect(function()
if sound.IsPlaying then
sound:Pause()
end
end)
stop.MouseButton1Click:Connect(function()
sound:Stop()
end)
local draggingVolume = false
slider.InputBegan:Connect(function(i)
if i.UserInputType == Enum.UserInputType.MouseButton1 then
draggingVolume = true
end
end)
slider.InputEnded:Connect(function(i)
if i.UserInputType == Enum.UserInputType.MouseButton1 then
draggingVolume = false
end
end)
RS.RenderStepped:Connect(function()
if draggingVolume then
local x = math.clamp((UIS:GetMouseLocation().X - slider.AbsolutePosition.X)/slider.AbsoluteSize.X,0,1)
sound.Volume = x
fill.Size = UDim2.fromScale(x,1)
end
end)
local draggingWindow = false
local dragInput, mousePos, framePos
header.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
draggingWindow = true
mousePos = input.Position
framePos = main.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
draggingWindow = false
end
end)
end
end)
header.InputChanged:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
dragInput = input
end
end)
UIS.InputChanged:Connect(function(input)
if input == dragInput and draggingWindow then
local delta = input.Position - mousePos
main.Position = UDim2.new(
framePos.X.Scale,
framePos.X.Offset + delta.X,
framePos.Y.Scale,
framePos.Y.Offset + delta.Y
)
end
end)
closeBtn.MouseButton1Click:Connect(function()
main.Visible = false
end)
UIS.InputBegan:Connect(function(input, gp)
if gp then return end
if input.KeyCode == Enum.KeyCode.KeypadMultiply or input.KeyCode == Enum.KeyCode.Multiply then
main.Visible = not main.Visible
end
end)
Comments
No comments yet
Be the first to share your thoughts!