Загрузка данных


local part = Instance.new("Part")
part.Name = "MusicPart"
part.Size = Vector3.new(4, 1, 4)
part.Anchored = true
part.CanCollide = false
part.Position = Vector3.new(0, 5, 0)
part.Parent = workspace

local sound = Instance.new("Sound")
sound.Name = "MusicTrack"
sound.SoundId = "rbxassetid://YOUR_SOUND_ID"
sound.Looped = false
sound.Volume = 0.8
sound.Parent = part

local isPlaying = false

local function playMusic()
    if not isPlaying then
        sound:Play()
        isPlaying = true
        print("Музыка запущена!")
    end
end

local function stopMusic()
    if isPlaying then
        sound:Stop()
        isPlaying = false
        print("Музыка остановлена!")
    end
end

sound.Ended:Connect(function()
    if isPlaying then
        sound:Play()
    end
end)

game:GetService("Players").PlayerAdded:Connect(function(player)
    game:GetService("ReplicatedStorage").DefaultChatSystemChatEvents.SayMessageRequest.OnServerEvent:Connect(function(player, message)
        local args = string.split(message, " ")
        local command = args[1]:lower()

        if command == "playpart" and player.Character then
            playMusic()
        elseif command == "stoppart" and player.Character then
            stopMusic()
        end
    end)
end)

local clickDetector = Instance.new("ClickDetector")
clickDetector.Parent = part

clickDetector.MouseClick:Connect(function(player)
    if isPlaying then
        stopMusic()
    else
        playMusic()
    end
end)

print("Музыкальная часть готова! Используйте команды:")
print("  /playpart - запустить музыку")
print("  /stoppart - остановить музыку")
print("  Кликните по части - переключить воспроизведение")