
Key Required

local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SoundService = game:GetService("SoundService")
local player = Players.LocalPlayer
-- Buat RemoteEvent kalau belum ada
local remote = ReplicatedStorage:FindFirstChild("GunPlaySound")
if not remote then
remote = Instance.new("RemoteEvent")
remote.Name = "GunPlaySound"
remote.Parent = ReplicatedStorage
end
local currentSound -- variabel global untuk menyimpan sound yang sedang dimainkan
-- Fungsi mainkan musik
local function playSound(assetId)
-- Hentikan dulu musik lama kalau ada
if currentSound then
currentSound:Stop()
currentSound:Destroy()
end
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://"..assetId
sound.Volume = 1
sound.Parent = SoundService
sound:Play()
currentSound = sound
sound.Ended:Connect(function()
sound:Destroy()
currentSound = nil
end)
print("🎵 Music started! Asset ID:", assetId) -- console developer
end
-- Fungsi stop musik
local function stopSound()
if currentSound then
currentSound:Stop()
currentSound:Destroy()
currentSound = nil
print("🛑 Music stopped!")
end
end
-- GUI
local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "ServerMusicGUI"
ScreenGui.Parent = player:WaitForChild("PlayerGui")
local mainFrame = Instance.new("Frame")
mainFrame.Size = UDim2.new(0, 320, 0, 200) -- tambah tinggi untuk tombol stop
mainFrame.Position = UDim2.new(0.5, -160, 0.5, -100)
mainFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
mainFrame.AnchorPoint = Vector2.new(0.5, 0.5)
mainFrame.Active = true
mainFrame.Draggable = true
mainFrame.Parent = ScreenGui
local uicorner = Instance.new("UICorner")
uicorner.CornerRadius = UDim.new(0, 12)
uicorner.Parent = mainFrame
local uistroke = Instance.new("UIStroke")
uistroke.Parent = mainFrame
uistroke.Thickness = 2
RunService.RenderStepped:Connect(function()
local time = tick()
local hue = (time % 5) / 5
uistroke.Color = Color3.fromHSV(hue, 1, 1)
end)
local title = Instance.new("TextLabel")
title.Size = UDim2.new(1,0,0,30)
title.Position = UDim2.new(0,0,0,0)
title.BackgroundTransparency = 1
title.Text = "🎵 Server Music Player"
title.TextColor3 = Color3.fromRGB(255,255,255)
title.Font = Enum.Font.GothamBold
title.TextSize = 18
title.Parent = mainFrame
local inputBox = Instance.new("TextBox")
inputBox.Size = UDim2.new(1,-20,0,40)
inputBox.Position = UDim2.new(0,10,0,50)
inputBox.PlaceholderText = "Enter Asset ID"
inputBox.BackgroundColor3 = Color3.fromRGB(50,50,50)
inputBox.TextColor3 = Color3.fromRGB(255,255,255)
inputBox.Font = Enum.Font.Gotham
inputBox.TextSize = 16
inputBox.Text = "" -- pastikan kosong saat mulai
inputBox.ClearTextOnFocus = false
inputBox.Parent = mainFrame
local inputCorner = Instance.new("UICorner")
inputCorner.CornerRadius = UDim.new(0,8)
inputCorner.Parent = inputBox
local playButton = Instance.new("TextButton")
playButton.Size = UDim2.new(1,-20,0,40)
playButton.Position = UDim2.new(0,10,0,100)
playButton.Text = "Play Music"
playButton.TextColor3 = Color3.fromRGB(255,255,255)
playButton.BackgroundColor3 = Color3.fromRGB(80,80,80)
playButton.Font = Enum.Font.GothamBold
playButton.TextSize = 16
playButton.Parent = mainFrame
local playCorner = Instance.new("UICorner")
playCorner.CornerRadius = UDim.new(0,8)
playCorner.Parent = playButton
local stopButton = Instance.new("TextButton")
stopButton.Size = UDim2.new(1,-20,0,40)
stopButton.Position = UDim2.new(0,10,0,150)
stopButton.Text = "Stop Music"
stopButton.TextColor3 = Color3.fromRGB(255,255,255)
stopButton.BackgroundColor3 = Color3.fromRGB(120,0,0)
stopButton.Font = Enum.Font.GothamBold
stopButton.TextSize = 16
stopButton.Parent = mainFrame
local stopCorner = Instance.new("UICorner")
stopCorner.CornerRadius = UDim.new(0,8)
stopCorner.Parent = stopButton
local closeButton = Instance.new("TextButton")
closeButton.Size = UDim2.new(0,25,0,25)
closeButton.Position = UDim2.new(1,-30,0,5)
closeButton.Text = "X"
closeButton.TextColor3 = Color3.fromRGB(255,255,255)
closeButton.BackgroundColor3 = Color3.fromRGB(180,0,0)
closeButton.Font = Enum.Font.GothamBold
closeButton.TextSize = 14
closeButton.Parent = mainFrame
local closeCorner = Instance.new("UICorner")
closeCorner.CornerRadius = UDim.new(0,6)
closeCorner.Parent = closeButton
closeButton.MouseButton1Click:Connect(function()
stopSound()
ScreenGui:Destroy()
end)
-- Tombol Play
playButton.MouseButton1Click:Connect(function()
local assetId = tonumber(inputBox.Text)
if not assetId then return end
remote:FireServer(assetId)
playSound(assetId)
TweenService:Create(playButton,TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),
{BackgroundColor3=Color3.fromRGB(100,100,100)}):Play()
wait(0.2)
TweenService:Create(playButton,TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),
{BackgroundColor3=Color3.fromRGB(80,80,80)}):Play()
end)
-- Tombol Stop
stopButton.MouseButton1Click:Connect(function()
stopSound()
TweenService:Create(stopButton,TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),
{BackgroundColor3=Color3.fromRGB(160,0,0)}):Play()
wait(0.2)
TweenService:Create(stopButton,TweenInfo.new(0.2,Enum.EasingStyle.Quad,Enum.EasingDirection.Out),
{BackgroundColor3=Color3.fromRGB(120,0,0)}):Play()
end)No comments yet for this script.



